1 /* Convert function calls to rtl insns, for GNU C compiler.
2 Copyright (C) 1989, 1992 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
26 #include "insn-flags.h"
28 /* Decide whether a function's arguments should be processed
29 from first to last or from last to first.
31 They should if the stack and args grow in opposite directions, but
32 only if we have push insns. */
36 #if defined (STACK_GROWS_DOWNWARD) != defined (ARGS_GROW_DOWNARD)
37 #define PUSH_ARGS_REVERSED /* If it's last to first */
42 /* Like STACK_BOUNDARY but in units of bytes, not bits. */
43 #define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
45 /* Data structure and subroutines used within expand_call. */
49 /* Tree node for this argument. */
51 /* Mode for value; TYPE_MODE unless promoted. */
52 enum machine_mode mode
;
53 /* Current RTL value for argument, or 0 if it isn't precomputed. */
55 /* Initially-compute RTL value for argument; only for const functions. */
57 /* Register to pass this argument in, 0 if passed on stack, or an
58 EXPR_LIST if the arg is to be copied into multiple different
61 /* If REG was promoted from the actual mode of the argument expression,
62 indicates whether the promotion is sign- or zero-extended. */
64 /* Number of registers to use. 0 means put the whole arg in registers.
65 Also 0 if not passed in registers. */
67 /* Non-zero if argument must be passed on stack.
68 Note that some arguments may be passed on the stack
69 even though pass_on_stack is zero, just because FUNCTION_ARG says so.
70 pass_on_stack identifies arguments that *cannot* go in registers. */
72 /* Offset of this argument from beginning of stack-args. */
73 struct args_size offset
;
74 /* Similar, but offset to the start of the stack slot. Different from
75 OFFSET if this arg pads downward. */
76 struct args_size slot_offset
;
77 /* Size of this argument on the stack, rounded up for any padding it gets,
78 parts of the argument passed in registers do not count.
79 If REG_PARM_STACK_SPACE is defined, then register parms
80 are counted here as well. */
81 struct args_size size
;
82 /* Location on the stack at which parameter should be stored. The store
83 has already been done if STACK == VALUE. */
85 /* Location on the stack of the start of this argument slot. This can
86 differ from STACK if this arg pads downward. This location is known
87 to be aligned to FUNCTION_ARG_BOUNDARY. */
89 #ifdef ACCUMULATE_OUTGOING_ARGS
90 /* Place that this stack area has been saved, if needed. */
93 #ifdef STRICT_ALIGNMENT
94 /* If an argument's alignment does not permit direct copying into registers,
95 copy in smaller-sized pieces into pseudos. These are stored in a
96 block pointed to by this field. The next field says how many
97 word-sized pseudos we made. */
103 #ifdef ACCUMULATE_OUTGOING_ARGS
104 /* A vector of one char per byte of stack space. A byte if non-zero if
105 the corresponding stack location has been used.
106 This vector is used to prevent a function call within an argument from
107 clobbering any stack already set up. */
108 static char *stack_usage_map
;
110 /* Size of STACK_USAGE_MAP. */
111 static int highest_outgoing_arg_in_use
;
113 /* stack_arg_under_construction is nonzero when an argument may be
114 initialized with a constructor call (including a C function that
115 returns a BLKmode struct) and expand_call must take special action
116 to make sure the object being constructed does not overlap the
117 argument list for the constructor call. */
118 int stack_arg_under_construction
;
121 static int calls_function
PROTO((tree
, int));
122 static void emit_call_1
PROTO((rtx
, tree
, int, int, rtx
, rtx
, int,
124 static void store_one_arg
PROTO ((struct arg_data
*, rtx
, int, int,
127 /* If WHICH is 1, return 1 if EXP contains a call to the built-in function
130 If WHICH is 0, return 1 if EXP contains a call to any function.
131 Actually, we only need return 1 if evaluating EXP would require pushing
132 arguments on the stack, but that is too difficult to compute, so we just
133 assume any function call might require the stack. */
136 calls_function (exp
, which
)
141 int type
= TREE_CODE_CLASS (TREE_CODE (exp
));
142 int length
= tree_code_length
[(int) TREE_CODE (exp
)];
144 /* Only expressions and references can contain calls. */
146 if (type
!= 'e' && type
!= '<' && type
!= '1' && type
!= '2' && type
!= 'r'
150 switch (TREE_CODE (exp
))
155 else if (TREE_CODE (TREE_OPERAND (exp
, 0)) == ADDR_EXPR
156 && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0))
158 && DECL_BUILT_IN (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0))
159 && (DECL_FUNCTION_CODE (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0))
163 /* Third operand is RTL. */
168 if (SAVE_EXPR_RTL (exp
) != 0)
176 for (local
= BLOCK_VARS (exp
); local
; local
= TREE_CHAIN (local
))
177 if (DECL_INITIAL (local
) != 0
178 && calls_function (DECL_INITIAL (local
), which
))
182 register tree subblock
;
184 for (subblock
= BLOCK_SUBBLOCKS (exp
);
186 subblock
= TREE_CHAIN (subblock
))
187 if (calls_function (subblock
, which
))
192 case METHOD_CALL_EXPR
:
196 case WITH_CLEANUP_EXPR
:
204 for (i
= 0; i
< length
; i
++)
205 if (TREE_OPERAND (exp
, i
) != 0
206 && calls_function (TREE_OPERAND (exp
, i
), which
))
212 /* Force FUNEXP into a form suitable for the address of a CALL,
213 and return that as an rtx. Also load the static chain register
214 if FNDECL is a nested function.
216 USE_INSNS points to a variable holding a chain of USE insns
217 to which a USE of the static chain
218 register should be added, if required. */
221 prepare_call_address (funexp
, fndecl
, use_insns
)
226 rtx static_chain_value
= 0;
228 funexp
= protect_from_queue (funexp
, 0);
231 /* Get possible static chain value for nested function in C. */
232 static_chain_value
= lookup_static_chain (fndecl
);
234 /* Make a valid memory address and copy constants thru pseudo-regs,
235 but not for a constant address if -fno-function-cse. */
236 if (GET_CODE (funexp
) != SYMBOL_REF
)
237 funexp
= memory_address (FUNCTION_MODE
, funexp
);
240 #ifndef NO_FUNCTION_CSE
241 if (optimize
&& ! flag_no_function_cse
)
242 #ifdef NO_RECURSIVE_FUNCTION_CSE
243 if (fndecl
!= current_function_decl
)
245 funexp
= force_reg (Pmode
, funexp
);
249 if (static_chain_value
!= 0)
251 emit_move_insn (static_chain_rtx
, static_chain_value
);
253 /* Put the USE insn in the chain we were passed. It will later be
254 output immediately in front of the CALL insn. */
255 push_to_sequence (*use_insns
);
256 emit_insn (gen_rtx (USE
, VOIDmode
, static_chain_rtx
));
257 *use_insns
= get_insns ();
264 /* Generate instructions to call function FUNEXP,
265 and optionally pop the results.
266 The CALL_INSN is the first insn generated.
268 FUNTYPE is the data type of the function, or, for a library call,
269 the identifier for the name of the call. This is given to the
270 macro RETURN_POPS_ARGS to determine whether this function pops its own args.
272 STACK_SIZE is the number of bytes of arguments on the stack,
273 rounded up to STACK_BOUNDARY; zero if the size is variable.
274 This is both to put into the call insn and
275 to generate explicit popping code if necessary.
277 STRUCT_VALUE_SIZE is the number of bytes wanted in a structure value.
278 It is zero if this call doesn't want a structure value.
280 NEXT_ARG_REG is the rtx that results from executing
281 FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1)
282 just after all the args have had their registers assigned.
283 This could be whatever you like, but normally it is the first
284 arg-register beyond those used for args in this call,
285 or 0 if all the arg-registers are used in this call.
286 It is passed on to `gen_call' so you can put this info in the call insn.
288 VALREG is a hard register in which a value is returned,
289 or 0 if the call does not return a value.
291 OLD_INHIBIT_DEFER_POP is the value that `inhibit_defer_pop' had before
292 the args to this call were processed.
293 We restore `inhibit_defer_pop' to that value.
295 USE_INSNS is a chain of USE insns to be emitted immediately before
296 the actual CALL insn.
298 IS_CONST is true if this is a `const' call. */
301 emit_call_1 (funexp
, funtype
, stack_size
, struct_value_size
, next_arg_reg
,
302 valreg
, old_inhibit_defer_pop
, use_insns
, is_const
)
306 int struct_value_size
;
309 int old_inhibit_defer_pop
;
313 rtx stack_size_rtx
= GEN_INT (stack_size
);
314 rtx struct_value_size_rtx
= GEN_INT (struct_value_size
);
316 int already_popped
= 0;
318 /* Ensure address is valid. SYMBOL_REF is already valid, so no need,
319 and we don't want to load it into a register as an optimization,
320 because prepare_call_address already did it if it should be done. */
321 if (GET_CODE (funexp
) != SYMBOL_REF
)
322 funexp
= memory_address (FUNCTION_MODE
, funexp
);
324 #ifndef ACCUMULATE_OUTGOING_ARGS
325 #if defined (HAVE_call_pop) && defined (HAVE_call_value_pop)
326 if (HAVE_call_pop
&& HAVE_call_value_pop
327 && (RETURN_POPS_ARGS (funtype
, stack_size
) > 0 || stack_size
== 0))
329 rtx n_pop
= GEN_INT (RETURN_POPS_ARGS (funtype
, stack_size
));
332 /* If this subroutine pops its own args, record that in the call insn
333 if possible, for the sake of frame pointer elimination. */
335 pat
= gen_call_value_pop (valreg
,
336 gen_rtx (MEM
, FUNCTION_MODE
, funexp
),
337 stack_size_rtx
, next_arg_reg
, n_pop
);
339 pat
= gen_call_pop (gen_rtx (MEM
, FUNCTION_MODE
, funexp
),
340 stack_size_rtx
, next_arg_reg
, n_pop
);
342 emit_call_insn (pat
);
349 #if defined (HAVE_call) && defined (HAVE_call_value)
350 if (HAVE_call
&& HAVE_call_value
)
353 emit_call_insn (gen_call_value (valreg
,
354 gen_rtx (MEM
, FUNCTION_MODE
, funexp
),
355 stack_size_rtx
, next_arg_reg
,
358 emit_call_insn (gen_call (gen_rtx (MEM
, FUNCTION_MODE
, funexp
),
359 stack_size_rtx
, next_arg_reg
,
360 struct_value_size_rtx
));
366 /* Find the CALL insn we just emitted and write the USE insns before it. */
367 for (call_insn
= get_last_insn ();
368 call_insn
&& GET_CODE (call_insn
) != CALL_INSN
;
369 call_insn
= PREV_INSN (call_insn
))
375 /* Put the USE insns before the CALL. */
376 emit_insns_before (use_insns
, call_insn
);
378 /* If this is a const call, then set the insn's unchanging bit. */
380 CONST_CALL_P (call_insn
) = 1;
382 /* Restore this now, so that we do defer pops for this call's args
383 if the context of the call as a whole permits. */
384 inhibit_defer_pop
= old_inhibit_defer_pop
;
386 #ifndef ACCUMULATE_OUTGOING_ARGS
387 /* If returning from the subroutine does not automatically pop the args,
388 we need an instruction to pop them sooner or later.
389 Perhaps do it now; perhaps just record how much space to pop later.
391 If returning from the subroutine does pop the args, indicate that the
392 stack pointer will be changed. */
394 if (stack_size
!= 0 && RETURN_POPS_ARGS (funtype
, stack_size
) > 0)
397 emit_insn (gen_rtx (CLOBBER
, VOIDmode
, stack_pointer_rtx
));
398 stack_size
-= RETURN_POPS_ARGS (funtype
, stack_size
);
399 stack_size_rtx
= GEN_INT (stack_size
);
404 if (flag_defer_pop
&& inhibit_defer_pop
== 0 && !is_const
)
405 pending_stack_adjust
+= stack_size
;
407 adjust_stack (stack_size_rtx
);
412 /* Generate all the code for a function call
413 and return an rtx for its value.
414 Store the value in TARGET (specified as an rtx) if convenient.
415 If the value is stored in TARGET then TARGET is returned.
416 If IGNORE is nonzero, then we ignore the value of the function call. */
419 expand_call (exp
, target
, ignore
)
424 /* List of actual parameters. */
425 tree actparms
= TREE_OPERAND (exp
, 1);
426 /* RTX for the function to be called. */
428 /* Tree node for the function to be called (not the address!). */
430 /* Data type of the function. */
432 /* Declaration of the function being called,
433 or 0 if the function is computed (not known by name). */
437 /* Register in which non-BLKmode value will be returned,
438 or 0 if no value or if value is BLKmode. */
440 /* Address where we should return a BLKmode value;
441 0 if value not BLKmode. */
442 rtx structure_value_addr
= 0;
443 /* Nonzero if that address is being passed by treating it as
444 an extra, implicit first parameter. Otherwise,
445 it is passed by being copied directly into struct_value_rtx. */
446 int structure_value_addr_parm
= 0;
447 /* Size of aggregate value wanted, or zero if none wanted
448 or if we are using the non-reentrant PCC calling convention
449 or expecting the value in registers. */
450 int struct_value_size
= 0;
451 /* Nonzero if called function returns an aggregate in memory PCC style,
452 by returning the address of where to find it. */
453 int pcc_struct_value
= 0;
455 /* Number of actual parameters in this call, including struct value addr. */
457 /* Number of named args. Args after this are anonymous ones
458 and they must all go on the stack. */
460 /* Count arg position in order args appear. */
463 /* Vector of information about each argument.
464 Arguments are numbered in the order they will be pushed,
465 not the order they are written. */
466 struct arg_data
*args
;
468 /* Total size in bytes of all the stack-parms scanned so far. */
469 struct args_size args_size
;
470 /* Size of arguments before any adjustments (such as rounding). */
471 struct args_size original_args_size
;
472 /* Data on reg parms scanned so far. */
473 CUMULATIVE_ARGS args_so_far
;
474 /* Nonzero if a reg parm has been scanned. */
476 /* Nonzero if this is an indirect function call. */
477 int current_call_is_indirect
= 0;
479 /* Nonzero if we must avoid push-insns in the args for this call.
480 If stack space is allocated for register parameters, but not by the
481 caller, then it is preallocated in the fixed part of the stack frame.
482 So the entire argument block must then be preallocated (i.e., we
483 ignore PUSH_ROUNDING in that case). */
485 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
486 int must_preallocate
= 1;
489 int must_preallocate
= 0;
491 int must_preallocate
= 1;
495 /* Size of the stack reserved for parameter registers. */
496 int reg_parm_stack_space
= 0;
498 /* 1 if scanning parms front to back, -1 if scanning back to front. */
500 /* Address of space preallocated for stack parms
501 (on machines that lack push insns), or 0 if space not preallocated. */
504 /* Nonzero if it is plausible that this is a call to alloca. */
506 /* Nonzero if this is a call to setjmp or a related function. */
508 /* Nonzero if this is a call to `longjmp'. */
510 /* Nonzero if this is a call to an inline function. */
511 int is_integrable
= 0;
512 /* Nonzero if this is a call to a `const' function.
513 Note that only explicitly named functions are handled as `const' here. */
515 /* Nonzero if this is a call to a `volatile' function. */
517 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
518 /* Define the boundary of the register parm stack space that needs to be
520 int low_to_save
= -1, high_to_save
;
521 rtx save_area
= 0; /* Place that it is saved */
524 #ifdef ACCUMULATE_OUTGOING_ARGS
525 int initial_highest_arg_in_use
= highest_outgoing_arg_in_use
;
526 char *initial_stack_usage_map
= stack_usage_map
;
529 rtx old_stack_level
= 0;
531 int old_stack_arg_under_construction
;
532 int old_inhibit_defer_pop
= inhibit_defer_pop
;
533 tree old_cleanups
= cleanups_this_call
;
540 /* See if we can find a DECL-node for the actual function.
541 As a result, decide whether this is a call to an integrable function. */
543 p
= TREE_OPERAND (exp
, 0);
544 if (TREE_CODE (p
) == ADDR_EXPR
)
546 fndecl
= TREE_OPERAND (p
, 0);
547 if (TREE_CODE (fndecl
) != FUNCTION_DECL
)
549 /* May still be a `const' function if it is
550 a call through a pointer-to-const.
551 But we don't handle that. */
557 && fndecl
!= current_function_decl
558 && DECL_SAVED_INSNS (fndecl
))
560 else if (! TREE_ADDRESSABLE (fndecl
))
562 /* In case this function later becomes inlinable,
563 record that there was already a non-inline call to it.
565 Use abstraction instead of setting TREE_ADDRESSABLE
567 if (DECL_INLINE (fndecl
) && extra_warnings
&& warn_inline
569 warning_with_decl (fndecl
, "can't inline call to `%s' which was declared inline");
570 mark_addressable (fndecl
);
573 if (TREE_READONLY (fndecl
) && ! TREE_THIS_VOLATILE (fndecl
)
574 && TYPE_MODE (TREE_TYPE (exp
)) != VOIDmode
)
579 is_volatile
= TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (p
)));
581 #ifdef REG_PARM_STACK_SPACE
582 #ifdef MAYBE_REG_PARM_STACK_SPACE
583 reg_parm_stack_space
= MAYBE_REG_PARM_STACK_SPACE
;
585 reg_parm_stack_space
= REG_PARM_STACK_SPACE (fndecl
);
589 /* Warn if this value is an aggregate type,
590 regardless of which calling convention we are using for it. */
591 if (warn_aggregate_return
592 && (TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
593 || TREE_CODE (TREE_TYPE (exp
)) == UNION_TYPE
594 || TREE_CODE (TREE_TYPE (exp
)) == QUAL_UNION_TYPE
595 || TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
))
596 warning ("function call has aggregate value");
598 /* Set up a place to return a structure. */
600 /* Cater to broken compilers. */
601 if (aggregate_value_p (exp
))
603 /* This call returns a big structure. */
606 #ifdef PCC_STATIC_STRUCT_RETURN
608 pcc_struct_value
= 1;
609 is_integrable
= 0; /* Easier than making that case work right. */
611 #else /* not PCC_STATIC_STRUCT_RETURN */
613 struct_value_size
= int_size_in_bytes (TREE_TYPE (exp
));
615 if (struct_value_size
< 0)
618 if (target
&& GET_CODE (target
) == MEM
)
619 structure_value_addr
= XEXP (target
, 0);
622 /* Assign a temporary on the stack to hold the value. */
624 /* For variable-sized objects, we must be called with a target
625 specified. If we were to allocate space on the stack here,
626 we would have no way of knowing when to free it. */
629 = XEXP (assign_stack_temp (BLKmode
, struct_value_size
, 1), 0);
633 #endif /* not PCC_STATIC_STRUCT_RETURN */
636 /* If called function is inline, try to integrate it. */
641 rtx before_call
= get_last_insn ();
643 temp
= expand_inline_function (fndecl
, actparms
, target
,
644 ignore
, TREE_TYPE (exp
),
645 structure_value_addr
);
647 /* If inlining succeeded, return. */
648 if ((HOST_WIDE_INT
) temp
!= -1)
650 /* Perform all cleanups needed for the arguments of this call
651 (i.e. destructors in C++). It is ok if these destructors
652 clobber RETURN_VALUE_REG, because the only time we care about
653 this is when TARGET is that register. But in C++, we take
654 care to never return that register directly. */
655 expand_cleanups_to (old_cleanups
);
657 #ifdef ACCUMULATE_OUTGOING_ARGS
658 /* If the outgoing argument list must be preserved, push
659 the stack before executing the inlined function if it
662 for (i
= reg_parm_stack_space
- 1; i
>= 0; i
--)
663 if (i
< highest_outgoing_arg_in_use
&& stack_usage_map
[i
] != 0)
666 if (stack_arg_under_construction
|| i
>= 0)
668 rtx insn
= NEXT_INSN (before_call
), seq
;
670 /* Look for a call in the inline function code.
671 If OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl)) is
672 nonzero then there is a call and it is not necessary
673 to scan the insns. */
675 if (OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl
)) == 0)
676 for (; insn
; insn
= NEXT_INSN (insn
))
677 if (GET_CODE (insn
) == CALL_INSN
)
682 /* Reserve enough stack space so that the largest
683 argument list of any function call in the inline
684 function does not overlap the argument list being
685 evaluated. This is usually an overestimate because
686 allocate_dynamic_stack_space reserves space for an
687 outgoing argument list in addition to the requested
688 space, but there is no way to ask for stack space such
689 that an argument list of a certain length can be
690 safely constructed. */
692 int adjust
= OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl
));
693 #ifdef REG_PARM_STACK_SPACE
694 /* Add the stack space reserved for register arguments
695 in the inline function. What is really needed is the
696 largest value of reg_parm_stack_space in the inline
697 function, but that is not available. Using the current
698 value of reg_parm_stack_space is wrong, but gives
699 correct results on all supported machines. */
700 adjust
+= reg_parm_stack_space
;
703 emit_stack_save (SAVE_BLOCK
, &old_stack_level
, NULL_RTX
);
704 allocate_dynamic_stack_space (GEN_INT (adjust
),
705 NULL_RTX
, BITS_PER_UNIT
);
708 emit_insns_before (seq
, NEXT_INSN (before_call
));
709 emit_stack_restore (SAVE_BLOCK
, old_stack_level
, NULL_RTX
);
714 /* If the result is equivalent to TARGET, return TARGET to simplify
715 checks in store_expr. They can be equivalent but not equal in the
716 case of a function that returns BLKmode. */
717 if (temp
!= target
&& rtx_equal_p (temp
, target
))
722 /* If inlining failed, mark FNDECL as needing to be compiled
723 separately after all. */
724 mark_addressable (fndecl
);
727 /* When calling a const function, we must pop the stack args right away,
728 so that the pop is deleted or moved with the call. */
732 function_call_count
++;
734 if (fndecl
&& DECL_NAME (fndecl
))
735 name
= IDENTIFIER_POINTER (DECL_NAME (fndecl
));
737 /* On some machines (such as the PA) indirect calls have a different
738 calling convention than normal calls. FUNCTION_ARG in the target
739 description can look at current_call_is_indirect to determine which
740 calling convention to use. */
741 current_call_is_indirect
= (fndecl
== 0);
743 = TREE_CODE (TREE_OPERAND (exp
, 0)) == NON_LVALUE_EXPR
? 1 : 0;
747 /* Unless it's a call to a specific function that isn't alloca,
748 if it has one argument, we must assume it might be alloca. */
751 (!(fndecl
!= 0 && strcmp (name
, "alloca"))
753 && TREE_CHAIN (actparms
) == 0);
755 /* We assume that alloca will always be called by name. It
756 makes no sense to pass it as a pointer-to-function to
757 anything that does not understand its behavior. */
759 (name
&& ((IDENTIFIER_LENGTH (DECL_NAME (fndecl
)) == 6
761 && ! strcmp (name
, "alloca"))
762 || (IDENTIFIER_LENGTH (DECL_NAME (fndecl
)) == 16
764 && ! strcmp (name
, "__builtin_alloca"))));
767 /* See if this is a call to a function that can return more than once
768 or a call to longjmp. */
773 if (name
!= 0 && IDENTIFIER_LENGTH (DECL_NAME (fndecl
)) <= 15)
778 tname
+= ((name
[1] == '_' && name
[2] == 'x') ? 3 : 1);
784 && (! strcmp (tname
, "setjmp")
785 || ! strcmp (tname
, "setjmp_syscall")))
787 && ! strcmp (tname
, "sigsetjmp"))
789 && ! strcmp (tname
, "savectx")));
791 && ! strcmp (tname
, "siglongjmp"))
794 else if ((tname
[0] == 'q' && tname
[1] == 's'
795 && ! strcmp (tname
, "qsetjmp"))
796 || (tname
[0] == 'v' && tname
[1] == 'f'
797 && ! strcmp (tname
, "vfork")))
800 else if (tname
[0] == 'l' && tname
[1] == 'o'
801 && ! strcmp (tname
, "longjmp"))
806 current_function_calls_alloca
= 1;
808 /* Don't let pending stack adjusts add up to too much.
809 Also, do all pending adjustments now
810 if there is any chance this might be a call to alloca. */
812 if (pending_stack_adjust
>= 32
813 || (pending_stack_adjust
> 0 && may_be_alloca
))
814 do_pending_stack_adjust ();
816 /* Operand 0 is a pointer-to-function; get the type of the function. */
817 funtype
= TREE_TYPE (TREE_OPERAND (exp
, 0));
818 if (TREE_CODE (funtype
) != POINTER_TYPE
)
820 funtype
= TREE_TYPE (funtype
);
822 /* Push the temporary stack slot level so that we can free temporaries used
823 by each of the arguments separately. */
826 /* Start updating where the next arg would go. */
827 INIT_CUMULATIVE_ARGS (args_so_far
, funtype
, NULL_RTX
);
829 /* If struct_value_rtx is 0, it means pass the address
830 as if it were an extra parameter. */
831 if (structure_value_addr
&& struct_value_rtx
== 0)
833 #ifdef ACCUMULATE_OUTGOING_ARGS
834 /* If the stack will be adjusted, make sure the structure address
835 does not refer to virtual_outgoing_args_rtx. */
836 rtx temp
= (stack_arg_under_construction
837 ? copy_addr_to_reg (structure_value_addr
)
838 : force_reg (Pmode
, structure_value_addr
));
840 rtx temp
= force_reg (Pmode
, structure_value_addr
);
844 = tree_cons (error_mark_node
,
845 make_tree (build_pointer_type (TREE_TYPE (funtype
)),
848 structure_value_addr_parm
= 1;
851 /* Count the arguments and set NUM_ACTUALS. */
852 for (p
= actparms
, i
= 0; p
; p
= TREE_CHAIN (p
)) i
++;
855 /* Compute number of named args.
856 Normally, don't include the last named arg if anonymous args follow.
857 (If no anonymous args follow, the result of list_length
858 is actually one too large.)
860 If SETUP_INCOMING_VARARGS is defined, this machine will be able to
861 place unnamed args that were passed in registers into the stack. So
862 treat all args as named. This allows the insns emitting for a specific
863 argument list to be independent of the function declaration.
865 If SETUP_INCOMING_VARARGS is not defined, we do not have any reliable
866 way to pass unnamed args in registers, so we must force them into
868 #ifndef SETUP_INCOMING_VARARGS
869 if (TYPE_ARG_TYPES (funtype
) != 0)
871 = list_length (TYPE_ARG_TYPES (funtype
)) - 1
872 /* Count the struct value address, if it is passed as a parm. */
873 + structure_value_addr_parm
;
876 /* If we know nothing, treat all args as named. */
877 n_named_args
= num_actuals
;
879 /* Make a vector to hold all the information about each arg. */
880 args
= (struct arg_data
*) alloca (num_actuals
* sizeof (struct arg_data
));
881 bzero (args
, num_actuals
* sizeof (struct arg_data
));
883 args_size
.constant
= 0;
886 /* In this loop, we consider args in the order they are written.
887 We fill up ARGS from the front of from the back if necessary
888 so that in any case the first arg to be pushed ends up at the front. */
890 #ifdef PUSH_ARGS_REVERSED
891 i
= num_actuals
- 1, inc
= -1;
892 /* In this case, must reverse order of args
893 so that we compute and push the last arg first. */
898 /* I counts args in order (to be) pushed; ARGPOS counts in order written. */
899 for (p
= actparms
, argpos
= 0; p
; p
= TREE_CHAIN (p
), i
+= inc
, argpos
++)
901 tree type
= TREE_TYPE (TREE_VALUE (p
));
902 enum machine_mode mode
;
904 args
[i
].tree_value
= TREE_VALUE (p
);
906 /* Replace erroneous argument with constant zero. */
907 if (type
== error_mark_node
|| TYPE_SIZE (type
) == 0)
908 args
[i
].tree_value
= integer_zero_node
, type
= integer_type_node
;
910 /* Decide where to pass this arg.
912 args[i].reg is nonzero if all or part is passed in registers.
914 args[i].partial is nonzero if part but not all is passed in registers,
915 and the exact value says how many words are passed in registers.
917 args[i].pass_on_stack is nonzero if the argument must at least be
918 computed on the stack. It may then be loaded back into registers
919 if args[i].reg is nonzero.
921 These decisions are driven by the FUNCTION_... macros and must agree
922 with those made by function.c. */
924 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
925 /* See if this argument should be passed by invisible reference. */
926 if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far
, TYPE_MODE (type
), type
,
927 argpos
< n_named_args
))
929 #ifdef FUNCTION_ARG_CALLEE_COPIES
930 if (FUNCTION_ARG_CALLEE_COPIES (args_so_far
, TYPE_MODE (type
), type
,
931 argpos
< n_named_args
)
932 /* If it's in a register, we must make a copy of it too. */
933 /* ??? Is this a sufficient test? Is there a better one? */
934 && !(TREE_CODE (args
[i
].tree_value
) == VAR_DECL
935 && REG_P (DECL_RTL (args
[i
].tree_value
))))
937 args
[i
].tree_value
= build1 (ADDR_EXPR
,
938 build_pointer_type (type
),
940 type
= build_pointer_type (type
);
945 /* We make a copy of the object and pass the address to the
946 function being called. */
949 if (TYPE_SIZE (type
) == 0
950 || TREE_CODE (TYPE_SIZE (type
)) != INTEGER_CST
)
952 /* This is a variable-sized object. Make space on the stack
954 rtx size_rtx
= expr_size (TREE_VALUE (p
));
956 if (old_stack_level
== 0)
958 emit_stack_save (SAVE_BLOCK
, &old_stack_level
, NULL_RTX
);
959 old_pending_adj
= pending_stack_adjust
;
960 pending_stack_adjust
= 0;
963 copy
= gen_rtx (MEM
, BLKmode
,
964 allocate_dynamic_stack_space (size_rtx
,
970 int size
= int_size_in_bytes (type
);
971 copy
= assign_stack_temp (TYPE_MODE (type
), size
, 1);
974 store_expr (args
[i
].tree_value
, copy
, 0);
976 args
[i
].tree_value
= build1 (ADDR_EXPR
,
977 build_pointer_type (type
),
978 make_tree (type
, copy
));
979 type
= build_pointer_type (type
);
982 #endif /* FUNCTION_ARG_PASS_BY_REFERENCE */
984 mode
= TYPE_MODE (type
);
986 #ifdef PROMOTE_FUNCTION_ARGS
987 /* Compute the mode in which the arg is actually to be extended to. */
988 if (TREE_CODE (type
) == INTEGER_TYPE
|| TREE_CODE (type
) == ENUMERAL_TYPE
989 || TREE_CODE (type
) == BOOLEAN_TYPE
|| TREE_CODE (type
) == CHAR_TYPE
990 || TREE_CODE (type
) == REAL_TYPE
|| TREE_CODE (type
) == POINTER_TYPE
991 || TREE_CODE (type
) == OFFSET_TYPE
)
993 int unsignedp
= TREE_UNSIGNED (type
);
994 PROMOTE_MODE (mode
, unsignedp
, type
);
995 args
[i
].unsignedp
= unsignedp
;
1000 args
[i
].reg
= FUNCTION_ARG (args_so_far
, mode
, type
,
1001 argpos
< n_named_args
);
1002 #ifdef FUNCTION_ARG_PARTIAL_NREGS
1005 = FUNCTION_ARG_PARTIAL_NREGS (args_so_far
, mode
, type
,
1006 argpos
< n_named_args
);
1009 args
[i
].pass_on_stack
= MUST_PASS_IN_STACK (mode
, type
);
1011 /* If FUNCTION_ARG returned an (expr_list (nil) FOO), it means that
1012 we are to pass this arg in the register(s) designated by FOO, but
1013 also to pass it in the stack. */
1014 if (args
[i
].reg
&& GET_CODE (args
[i
].reg
) == EXPR_LIST
1015 && XEXP (args
[i
].reg
, 0) == 0)
1016 args
[i
].pass_on_stack
= 1, args
[i
].reg
= XEXP (args
[i
].reg
, 1);
1018 /* If this is an addressable type, we must preallocate the stack
1019 since we must evaluate the object into its final location.
1021 If this is to be passed in both registers and the stack, it is simpler
1023 if (TREE_ADDRESSABLE (type
)
1024 || (args
[i
].pass_on_stack
&& args
[i
].reg
!= 0))
1025 must_preallocate
= 1;
1027 /* If this is an addressable type, we cannot pre-evaluate it. Thus,
1028 we cannot consider this function call constant. */
1029 if (TREE_ADDRESSABLE (type
))
1032 /* Compute the stack-size of this argument. */
1033 if (args
[i
].reg
== 0 || args
[i
].partial
!= 0
1034 #ifdef REG_PARM_STACK_SPACE
1035 || reg_parm_stack_space
> 0
1037 || args
[i
].pass_on_stack
)
1038 locate_and_pad_parm (mode
, type
,
1039 #ifdef STACK_PARMS_IN_REG_PARM_AREA
1044 fndecl
, &args_size
, &args
[i
].offset
,
1047 #ifndef ARGS_GROW_DOWNWARD
1048 args
[i
].slot_offset
= args_size
;
1051 #ifndef REG_PARM_STACK_SPACE
1052 /* If a part of the arg was put into registers,
1053 don't include that part in the amount pushed. */
1054 if (! args
[i
].pass_on_stack
)
1055 args
[i
].size
.constant
-= ((args
[i
].partial
* UNITS_PER_WORD
)
1056 / (PARM_BOUNDARY
/ BITS_PER_UNIT
)
1057 * (PARM_BOUNDARY
/ BITS_PER_UNIT
));
1060 /* Update ARGS_SIZE, the total stack space for args so far. */
1062 args_size
.constant
+= args
[i
].size
.constant
;
1063 if (args
[i
].size
.var
)
1065 ADD_PARM_SIZE (args_size
, args
[i
].size
.var
);
1068 /* Since the slot offset points to the bottom of the slot,
1069 we must record it after incrementing if the args grow down. */
1070 #ifdef ARGS_GROW_DOWNWARD
1071 args
[i
].slot_offset
= args_size
;
1073 args
[i
].slot_offset
.constant
= -args_size
.constant
;
1076 SUB_PARM_SIZE (args
[i
].slot_offset
, args_size
.var
);
1080 /* Increment ARGS_SO_FAR, which has info about which arg-registers
1081 have been used, etc. */
1083 FUNCTION_ARG_ADVANCE (args_so_far
, TYPE_MODE (type
), type
,
1084 argpos
< n_named_args
);
1087 #ifdef FINAL_REG_PARM_STACK_SPACE
1088 reg_parm_stack_space
= FINAL_REG_PARM_STACK_SPACE (args_size
.constant
,
1092 /* Compute the actual size of the argument block required. The variable
1093 and constant sizes must be combined, the size may have to be rounded,
1094 and there may be a minimum required size. */
1096 original_args_size
= args_size
;
1099 /* If this function requires a variable-sized argument list, don't try to
1100 make a cse'able block for this call. We may be able to do this
1101 eventually, but it is too complicated to keep track of what insns go
1102 in the cse'able block and which don't. */
1105 must_preallocate
= 1;
1107 args_size
.var
= ARGS_SIZE_TREE (args_size
);
1108 args_size
.constant
= 0;
1110 #ifdef STACK_BOUNDARY
1111 if (STACK_BOUNDARY
!= BITS_PER_UNIT
)
1112 args_size
.var
= round_up (args_size
.var
, STACK_BYTES
);
1115 #ifdef REG_PARM_STACK_SPACE
1116 if (reg_parm_stack_space
> 0)
1119 = size_binop (MAX_EXPR
, args_size
.var
,
1120 size_int (REG_PARM_STACK_SPACE (fndecl
)));
1122 #ifndef OUTGOING_REG_PARM_STACK_SPACE
1123 /* The area corresponding to register parameters is not to count in
1124 the size of the block we need. So make the adjustment. */
1126 = size_binop (MINUS_EXPR
, args_size
.var
,
1127 size_int (reg_parm_stack_space
));
1134 #ifdef STACK_BOUNDARY
1135 args_size
.constant
= (((args_size
.constant
+ (STACK_BYTES
- 1))
1136 / STACK_BYTES
) * STACK_BYTES
);
1139 #ifdef REG_PARM_STACK_SPACE
1140 args_size
.constant
= MAX (args_size
.constant
,
1141 reg_parm_stack_space
);
1142 #ifdef MAYBE_REG_PARM_STACK_SPACE
1143 if (reg_parm_stack_space
== 0)
1144 args_size
.constant
= 0;
1146 #ifndef OUTGOING_REG_PARM_STACK_SPACE
1147 args_size
.constant
-= reg_parm_stack_space
;
1152 /* See if we have or want to preallocate stack space.
1154 If we would have to push a partially-in-regs parm
1155 before other stack parms, preallocate stack space instead.
1157 If the size of some parm is not a multiple of the required stack
1158 alignment, we must preallocate.
1160 If the total size of arguments that would otherwise create a copy in
1161 a temporary (such as a CALL) is more than half the total argument list
1162 size, preallocation is faster.
1164 Another reason to preallocate is if we have a machine (like the m88k)
1165 where stack alignment is required to be maintained between every
1166 pair of insns, not just when the call is made. However, we assume here
1167 that such machines either do not have push insns (and hence preallocation
1168 would occur anyway) or the problem is taken care of with
1171 if (! must_preallocate
)
1173 int partial_seen
= 0;
1174 int copy_to_evaluate_size
= 0;
1176 for (i
= 0; i
< num_actuals
&& ! must_preallocate
; i
++)
1178 if (args
[i
].partial
> 0 && ! args
[i
].pass_on_stack
)
1180 else if (partial_seen
&& args
[i
].reg
== 0)
1181 must_preallocate
= 1;
1183 if (TYPE_MODE (TREE_TYPE (args
[i
].tree_value
)) == BLKmode
1184 && (TREE_CODE (args
[i
].tree_value
) == CALL_EXPR
1185 || TREE_CODE (args
[i
].tree_value
) == TARGET_EXPR
1186 || TREE_CODE (args
[i
].tree_value
) == COND_EXPR
1187 || TREE_ADDRESSABLE (TREE_TYPE (args
[i
].tree_value
))))
1188 copy_to_evaluate_size
1189 += int_size_in_bytes (TREE_TYPE (args
[i
].tree_value
));
1192 if (copy_to_evaluate_size
* 2 >= args_size
.constant
1193 && args_size
.constant
> 0)
1194 must_preallocate
= 1;
1197 /* If the structure value address will reference the stack pointer, we must
1198 stabilize it. We don't need to do this if we know that we are not going
1199 to adjust the stack pointer in processing this call. */
1201 if (structure_value_addr
1202 && (reg_mentioned_p (virtual_stack_dynamic_rtx
, structure_value_addr
)
1203 || reg_mentioned_p (virtual_outgoing_args_rtx
, structure_value_addr
))
1205 #ifndef ACCUMULATE_OUTGOING_ARGS
1206 || args_size
.constant
1209 structure_value_addr
= copy_to_reg (structure_value_addr
);
1211 /* If this function call is cse'able, precompute all the parameters.
1212 Note that if the parameter is constructed into a temporary, this will
1213 cause an additional copy because the parameter will be constructed
1214 into a temporary location and then copied into the outgoing arguments.
1215 If a parameter contains a call to alloca and this function uses the
1216 stack, precompute the parameter. */
1218 /* If we preallocated the stack space, and some arguments must be passed
1219 on the stack, then we must precompute any parameter which contains a
1220 function call which will store arguments on the stack.
1221 Otherwise, evaluating the parameter may clobber previous parameters
1222 which have already been stored into the stack. */
1224 for (i
= 0; i
< num_actuals
; i
++)
1226 || ((args_size
.var
!= 0 || args_size
.constant
!= 0)
1227 && calls_function (args
[i
].tree_value
, 1))
1228 || (must_preallocate
&& (args_size
.var
!= 0 || args_size
.constant
!= 0)
1229 && calls_function (args
[i
].tree_value
, 0)))
1231 args
[i
].initial_value
= args
[i
].value
1232 = expand_expr (args
[i
].tree_value
, NULL_RTX
, VOIDmode
, 0);
1234 if (GET_MODE (args
[i
].value
) != VOIDmode
1235 && GET_MODE (args
[i
].value
) != args
[i
].mode
)
1236 args
[i
].value
= convert_to_mode (args
[i
].mode
, args
[i
].value
,
1238 preserve_temp_slots (args
[i
].value
);
1242 /* ANSI doesn't require a sequence point here,
1243 but PCC has one, so this will avoid some problems. */
1247 /* Now we are about to start emitting insns that can be deleted
1248 if a libcall is deleted. */
1252 /* If we have no actual push instructions, or shouldn't use them,
1253 make space for all args right now. */
1255 if (args_size
.var
!= 0)
1257 if (old_stack_level
== 0)
1259 emit_stack_save (SAVE_BLOCK
, &old_stack_level
, NULL_RTX
);
1260 old_pending_adj
= pending_stack_adjust
;
1261 pending_stack_adjust
= 0;
1262 #ifdef ACCUMULATE_OUTGOING_ARGS
1263 /* stack_arg_under_construction says whether a stack arg is
1264 being constructed at the old stack level. Pushing the stack
1265 gets a clean outgoing argument block. */
1266 old_stack_arg_under_construction
= stack_arg_under_construction
;
1267 stack_arg_under_construction
= 0;
1270 argblock
= push_block (ARGS_SIZE_RTX (args_size
), 0, 0);
1272 else if (must_preallocate
)
1274 /* Note that we must go through the motions of allocating an argument
1275 block even if the size is zero because we may be storing args
1276 in the area reserved for register arguments, which may be part of
1278 int needed
= args_size
.constant
;
1280 #ifdef ACCUMULATE_OUTGOING_ARGS
1281 /* Store the maximum argument space used. It will be pushed by the
1284 Since the stack pointer will never be pushed, it is possible for
1285 the evaluation of a parm to clobber something we have already
1286 written to the stack. Since most function calls on RISC machines
1287 do not use the stack, this is uncommon, but must work correctly.
1289 Therefore, we save any area of the stack that was already written
1290 and that we are using. Here we set up to do this by making a new
1291 stack usage map from the old one. The actual save will be done
1294 Another approach might be to try to reorder the argument
1295 evaluations to avoid this conflicting stack usage. */
1297 if (needed
> current_function_outgoing_args_size
)
1298 current_function_outgoing_args_size
= needed
;
1300 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
1301 /* Since we will be writing into the entire argument area, the
1302 map must be allocated for its entire size, not just the part that
1303 is the responsibility of the caller. */
1304 needed
+= reg_parm_stack_space
;
1307 #ifdef ARGS_GROW_DOWNWARD
1308 highest_outgoing_arg_in_use
= MAX (initial_highest_arg_in_use
,
1311 highest_outgoing_arg_in_use
= MAX (initial_highest_arg_in_use
, needed
);
1313 stack_usage_map
= (char *) alloca (highest_outgoing_arg_in_use
);
1315 if (initial_highest_arg_in_use
)
1316 bcopy (initial_stack_usage_map
, stack_usage_map
,
1317 initial_highest_arg_in_use
);
1319 if (initial_highest_arg_in_use
!= highest_outgoing_arg_in_use
)
1320 bzero (&stack_usage_map
[initial_highest_arg_in_use
],
1321 highest_outgoing_arg_in_use
- initial_highest_arg_in_use
);
1324 /* The address of the outgoing argument list must not be copied to a
1325 register here, because argblock would be left pointing to the
1326 wrong place after the call to allocate_dynamic_stack_space below. */
1328 argblock
= virtual_outgoing_args_rtx
;
1330 #else /* not ACCUMULATE_OUTGOING_ARGS */
1331 if (inhibit_defer_pop
== 0)
1333 /* Try to reuse some or all of the pending_stack_adjust
1334 to get this space. Maybe we can avoid any pushing. */
1335 if (needed
> pending_stack_adjust
)
1337 needed
-= pending_stack_adjust
;
1338 pending_stack_adjust
= 0;
1342 pending_stack_adjust
-= needed
;
1346 /* Special case this because overhead of `push_block' in this
1347 case is non-trivial. */
1349 argblock
= virtual_outgoing_args_rtx
;
1351 argblock
= push_block (GEN_INT (needed
), 0, 0);
1353 /* We only really need to call `copy_to_reg' in the case where push
1354 insns are going to be used to pass ARGBLOCK to a function
1355 call in ARGS. In that case, the stack pointer changes value
1356 from the allocation point to the call point, and hence
1357 the value of VIRTUAL_OUTGOING_ARGS_RTX changes as well.
1358 But might as well always do it. */
1359 argblock
= copy_to_reg (argblock
);
1360 #endif /* not ACCUMULATE_OUTGOING_ARGS */
1364 #ifdef ACCUMULATE_OUTGOING_ARGS
1365 /* The save/restore code in store_one_arg handles all cases except one:
1366 a constructor call (including a C function returning a BLKmode struct)
1367 to initialize an argument. */
1368 if (stack_arg_under_construction
)
1370 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
1371 rtx push_size
= GEN_INT (reg_parm_stack_space
+ args_size
.constant
);
1373 rtx push_size
= GEN_INT (args_size
.constant
);
1375 if (old_stack_level
== 0)
1377 emit_stack_save (SAVE_BLOCK
, &old_stack_level
, NULL_RTX
);
1378 old_pending_adj
= pending_stack_adjust
;
1379 pending_stack_adjust
= 0;
1380 /* stack_arg_under_construction says whether a stack arg is
1381 being constructed at the old stack level. Pushing the stack
1382 gets a clean outgoing argument block. */
1383 old_stack_arg_under_construction
= stack_arg_under_construction
;
1384 stack_arg_under_construction
= 0;
1385 /* Make a new map for the new argument list. */
1386 stack_usage_map
= (char *)alloca (highest_outgoing_arg_in_use
);
1387 bzero (stack_usage_map
, highest_outgoing_arg_in_use
);
1388 highest_outgoing_arg_in_use
= 0;
1390 allocate_dynamic_stack_space (push_size
, NULL_RTX
, BITS_PER_UNIT
);
1392 /* If argument evaluation might modify the stack pointer, copy the
1393 address of the argument list to a register. */
1394 for (i
= 0; i
< num_actuals
; i
++)
1395 if (args
[i
].pass_on_stack
)
1397 argblock
= copy_addr_to_reg (argblock
);
1403 /* If we preallocated stack space, compute the address of each argument.
1404 We need not ensure it is a valid memory address here; it will be
1405 validized when it is used. */
1408 rtx arg_reg
= argblock
;
1411 if (GET_CODE (argblock
) == PLUS
)
1412 arg_reg
= XEXP (argblock
, 0), arg_offset
= INTVAL (XEXP (argblock
, 1));
1414 for (i
= 0; i
< num_actuals
; i
++)
1416 rtx offset
= ARGS_SIZE_RTX (args
[i
].offset
);
1417 rtx slot_offset
= ARGS_SIZE_RTX (args
[i
].slot_offset
);
1420 /* Skip this parm if it will not be passed on the stack. */
1421 if (! args
[i
].pass_on_stack
&& args
[i
].reg
!= 0)
1424 if (GET_CODE (offset
) == CONST_INT
)
1425 addr
= plus_constant (arg_reg
, INTVAL (offset
));
1427 addr
= gen_rtx (PLUS
, Pmode
, arg_reg
, offset
);
1429 addr
= plus_constant (addr
, arg_offset
);
1430 args
[i
].stack
= gen_rtx (MEM
, args
[i
].mode
, addr
);
1432 if (GET_CODE (slot_offset
) == CONST_INT
)
1433 addr
= plus_constant (arg_reg
, INTVAL (slot_offset
));
1435 addr
= gen_rtx (PLUS
, Pmode
, arg_reg
, slot_offset
);
1437 addr
= plus_constant (addr
, arg_offset
);
1438 args
[i
].stack_slot
= gen_rtx (MEM
, args
[i
].mode
, addr
);
1442 #ifdef PUSH_ARGS_REVERSED
1443 #ifdef STACK_BOUNDARY
1444 /* If we push args individually in reverse order, perform stack alignment
1445 before the first push (the last arg). */
1447 anti_adjust_stack (GEN_INT (args_size
.constant
1448 - original_args_size
.constant
));
1452 /* Don't try to defer pops if preallocating, not even from the first arg,
1453 since ARGBLOCK probably refers to the SP. */
1457 /* Get the function to call, in the form of RTL. */
1459 /* Get a SYMBOL_REF rtx for the function address. */
1460 funexp
= XEXP (DECL_RTL (fndecl
), 0);
1462 /* Generate an rtx (probably a pseudo-register) for the address. */
1464 funexp
= expand_expr (TREE_OPERAND (exp
, 0), NULL_RTX
, VOIDmode
, 0);
1465 free_temp_slots (); /* FUNEXP can't be BLKmode */
1469 /* Figure out the register where the value, if any, will come back. */
1471 if (TYPE_MODE (TREE_TYPE (exp
)) != VOIDmode
1472 && ! structure_value_addr
)
1474 if (pcc_struct_value
)
1475 valreg
= hard_function_value (build_pointer_type (TREE_TYPE (exp
)),
1478 valreg
= hard_function_value (TREE_TYPE (exp
), fndecl
);
1481 /* Precompute all register parameters. It isn't safe to compute anything
1482 once we have started filling any specific hard regs. */
1484 for (i
= 0; i
< num_actuals
; i
++)
1485 if (args
[i
].reg
!= 0 && ! args
[i
].pass_on_stack
)
1489 if (args
[i
].value
== 0)
1491 args
[i
].value
= expand_expr (args
[i
].tree_value
, NULL_RTX
,
1493 preserve_temp_slots (args
[i
].value
);
1496 /* ANSI doesn't require a sequence point here,
1497 but PCC has one, so this will avoid some problems. */
1501 /* If we are to promote the function arg to a wider mode,
1504 if (GET_MODE (args
[i
].value
) != VOIDmode
1505 && GET_MODE (args
[i
].value
) != args
[i
].mode
)
1506 args
[i
].value
= convert_to_mode (args
[i
].mode
, args
[i
].value
,
1510 #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
1511 /* The argument list is the property of the called routine and it
1512 may clobber it. If the fixed area has been used for previous
1513 parameters, we must save and restore it.
1515 Here we compute the boundary of the that needs to be saved, if any. */
1517 #ifdef ARGS_GROW_DOWNWARD
1518 for (i
= 0; i
< reg_parm_stack_space
+ 1; i
++)
1520 for (i
= 0; i
< reg_parm_stack_space
; i
++)
1523 if (i
>= highest_outgoing_arg_in_use
1524 || stack_usage_map
[i
] == 0)
1527 if (low_to_save
== -1)
1533 if (low_to_save
>= 0)
1535 int num_to_save
= high_to_save
- low_to_save
+ 1;
1536 enum machine_mode save_mode
1537 = mode_for_size (num_to_save
* BITS_PER_UNIT
, MODE_INT
, 1);
1540 /* If we don't have the required alignment, must do this in BLKmode. */
1541 if ((low_to_save
& (MIN (GET_MODE_SIZE (save_mode
),
1542 BIGGEST_ALIGNMENT
/ UNITS_PER_WORD
) - 1)))
1543 save_mode
= BLKmode
;
1545 stack_area
= gen_rtx (MEM
, save_mode
,
1546 memory_address (save_mode
,
1548 #ifdef ARGS_GROW_DOWNWARD
1549 plus_constant (argblock
,
1552 plus_constant (argblock
,
1556 if (save_mode
== BLKmode
)
1558 save_area
= assign_stack_temp (BLKmode
, num_to_save
, 1);
1559 emit_block_move (validize_mem (save_area
), stack_area
,
1560 GEN_INT (num_to_save
),
1561 PARM_BOUNDARY
/ BITS_PER_UNIT
);
1565 save_area
= gen_reg_rtx (save_mode
);
1566 emit_move_insn (save_area
, stack_area
);
1572 /* Now store (and compute if necessary) all non-register parms.
1573 These come before register parms, since they can require block-moves,
1574 which could clobber the registers used for register parms.
1575 Parms which have partial registers are not stored here,
1576 but we do preallocate space here if they want that. */
1578 for (i
= 0; i
< num_actuals
; i
++)
1579 if (args
[i
].reg
== 0 || args
[i
].pass_on_stack
)
1580 store_one_arg (&args
[i
], argblock
, may_be_alloca
,
1581 args_size
.var
!= 0, fndecl
, reg_parm_stack_space
);
1583 #ifdef STRICT_ALIGNMENT
1584 /* If we have a parm that is passed in registers but not in memory
1585 and whose alignment does not permit a direct copy into registers,
1586 make a group of pseudos that correspond to each register that we
1589 for (i
= 0; i
< num_actuals
; i
++)
1590 if (args
[i
].reg
!= 0 && ! args
[i
].pass_on_stack
1591 && args
[i
].mode
== BLKmode
1592 && (TYPE_ALIGN (TREE_TYPE (args
[i
].tree_value
))
1593 < MIN (BIGGEST_ALIGNMENT
, BITS_PER_WORD
)))
1595 int bytes
= int_size_in_bytes (TREE_TYPE (args
[i
].tree_value
));
1597 args
[i
].n_aligned_regs
1598 = args
[i
].partial
? args
[i
].partial
1599 : (bytes
+ (UNITS_PER_WORD
- 1)) / UNITS_PER_WORD
;
1601 args
[i
].aligned_regs
= (rtx
*) alloca (sizeof (rtx
)
1602 * args
[i
].n_aligned_regs
);
1604 for (j
= 0; j
< args
[i
].n_aligned_regs
; j
++)
1606 rtx reg
= gen_reg_rtx (word_mode
);
1607 rtx word
= operand_subword_force (args
[i
].value
, j
, BLKmode
);
1608 int bitsize
= TYPE_ALIGN (TREE_TYPE (args
[i
].tree_value
));
1611 args
[i
].aligned_regs
[j
] = reg
;
1613 /* Clobber REG and move each partword into it. Ensure we don't
1614 go past the end of the structure. Note that the loop below
1615 works because we've already verified that padding
1616 and endianness are compatible. */
1618 emit_insn (gen_rtx (CLOBBER
, VOIDmode
, reg
));
1621 bitpos
< BITS_PER_WORD
&& bytes
> 0;
1622 bitpos
+= bitsize
, bytes
-= bitsize
/ BITS_PER_UNIT
)
1624 int xbitpos
= (BYTES_BIG_ENDIAN
1625 ? BITS_PER_WORD
- bitpos
- bitsize
1628 store_bit_field (reg
, bitsize
, xbitpos
, word_mode
,
1629 extract_bit_field (word
, bitsize
, xbitpos
, 1,
1630 NULL_RTX
, word_mode
,
1632 bitsize
/ BITS_PER_UNIT
,
1634 bitsize
/ BITS_PER_UNIT
, BITS_PER_WORD
);
1640 /* Now store any partially-in-registers parm.
1641 This is the last place a block-move can happen. */
1643 for (i
= 0; i
< num_actuals
; i
++)
1644 if (args
[i
].partial
!= 0 && ! args
[i
].pass_on_stack
)
1645 store_one_arg (&args
[i
], argblock
, may_be_alloca
,
1646 args_size
.var
!= 0, fndecl
, reg_parm_stack_space
);
1648 #ifndef PUSH_ARGS_REVERSED
1649 #ifdef STACK_BOUNDARY
1650 /* If we pushed args in forward order, perform stack alignment
1651 after pushing the last arg. */
1653 anti_adjust_stack (GEN_INT (args_size
.constant
1654 - original_args_size
.constant
));
1658 /* If register arguments require space on the stack and stack space
1659 was not preallocated, allocate stack space here for arguments
1660 passed in registers. */
1661 #if ! defined(ALLOCATE_OUTGOING_ARGS) && defined(OUTGOING_REG_PARM_STACK_SPACE)
1662 if (must_preallocate
== 0 && reg_parm_stack_space
> 0)
1663 anti_adjust_stack (GEN_INT (reg_parm_stack_space
));
1666 /* Pass the function the address in which to return a structure value. */
1667 if (structure_value_addr
&& ! structure_value_addr_parm
)
1669 emit_move_insn (struct_value_rtx
,
1671 force_operand (structure_value_addr
,
1673 if (GET_CODE (struct_value_rtx
) == REG
)
1675 push_to_sequence (use_insns
);
1676 emit_insn (gen_rtx (USE
, VOIDmode
, struct_value_rtx
));
1677 use_insns
= get_insns ();
1682 /* Now do the register loads required for any wholly-register parms or any
1683 parms which are passed both on the stack and in a register. Their
1684 expressions were already evaluated.
1686 Mark all register-parms as living through the call, putting these USE
1687 insns in a list headed by USE_INSNS. */
1689 for (i
= 0; i
< num_actuals
; i
++)
1691 rtx list
= args
[i
].reg
;
1692 int partial
= args
[i
].partial
;
1699 /* Process each register that needs to get this arg. */
1700 if (GET_CODE (list
) == EXPR_LIST
)
1701 reg
= XEXP (list
, 0), list
= XEXP (list
, 1);
1703 reg
= list
, list
= 0;
1705 /* Set to non-zero if must move a word at a time, even if just one
1706 word (e.g, partial == 1 && mode == DFmode). Set to zero if
1707 we just use a normal move insn. */
1708 nregs
= (partial
? partial
1709 : (TYPE_MODE (TREE_TYPE (args
[i
].tree_value
)) == BLKmode
1710 ? ((int_size_in_bytes (TREE_TYPE (args
[i
].tree_value
))
1711 + (UNITS_PER_WORD
- 1)) / UNITS_PER_WORD
)
1714 /* If simple case, just do move. If normal partial, store_one_arg
1715 has already loaded the register for us. In all other cases,
1716 load the register(s) from memory. */
1719 emit_move_insn (reg
, args
[i
].value
);
1721 #ifdef STRICT_ALIGNMENT
1722 /* If we have pre-computed the values to put in the registers in
1723 the case of non-aligned structures, copy them in now. */
1725 else if (args
[i
].n_aligned_regs
!= 0)
1726 for (j
= 0; j
< args
[i
].n_aligned_regs
; j
++)
1727 emit_move_insn (gen_rtx (REG
, word_mode
, REGNO (reg
) + j
),
1728 args
[i
].aligned_regs
[j
]);
1731 else if (args
[i
].partial
== 0 || args
[i
].pass_on_stack
)
1732 move_block_to_reg (REGNO (reg
),
1733 validize_mem (args
[i
].value
), nregs
,
1736 push_to_sequence (use_insns
);
1738 emit_insn (gen_rtx (USE
, VOIDmode
, reg
));
1740 use_regs (REGNO (reg
), nregs
);
1741 use_insns
= get_insns ();
1744 /* PARTIAL referred only to the first register, so clear it for the
1750 /* Perform postincrements before actually calling the function. */
1753 /* All arguments and registers used for the call must be set up by now! */
1755 funexp
= prepare_call_address (funexp
, fndecl
, &use_insns
);
1757 /* Generate the actual call instruction. */
1758 emit_call_1 (funexp
, funtype
, args_size
.constant
, struct_value_size
,
1759 FUNCTION_ARG (args_so_far
, VOIDmode
, void_type_node
, 1),
1760 valreg
, old_inhibit_defer_pop
, use_insns
, is_const
);
1762 /* If call is cse'able, make appropriate pair of reg-notes around it.
1763 Test valreg so we don't crash; may safely ignore `const'
1764 if return type is void. */
1765 if (is_const
&& valreg
!= 0)
1768 rtx temp
= gen_reg_rtx (GET_MODE (valreg
));
1771 /* Construct an "equal form" for the value which mentions all the
1772 arguments in order as well as the function name. */
1773 #ifdef PUSH_ARGS_REVERSED
1774 for (i
= 0; i
< num_actuals
; i
++)
1775 note
= gen_rtx (EXPR_LIST
, VOIDmode
, args
[i
].initial_value
, note
);
1777 for (i
= num_actuals
- 1; i
>= 0; i
--)
1778 note
= gen_rtx (EXPR_LIST
, VOIDmode
, args
[i
].initial_value
, note
);
1780 note
= gen_rtx (EXPR_LIST
, VOIDmode
, funexp
, note
);
1782 insns
= get_insns ();
1785 emit_libcall_block (insns
, temp
, valreg
, note
);
1790 /* For calls to `setjmp', etc., inform flow.c it should complain
1791 if nonvolatile values are live. */
1795 emit_note (name
, NOTE_INSN_SETJMP
);
1796 current_function_calls_setjmp
= 1;
1800 current_function_calls_longjmp
= 1;
1802 /* Notice functions that cannot return.
1803 If optimizing, insns emitted below will be dead.
1804 If not optimizing, they will exist, which is useful
1805 if the user uses the `return' command in the debugger. */
1807 if (is_volatile
|| is_longjmp
)
1810 /* If value type not void, return an rtx for the value. */
1812 /* If there are cleanups to be called, don't use a hard reg as target. */
1813 if (cleanups_this_call
!= old_cleanups
1814 && target
&& REG_P (target
)
1815 && REGNO (target
) < FIRST_PSEUDO_REGISTER
)
1818 if (TYPE_MODE (TREE_TYPE (exp
)) == VOIDmode
1821 target
= const0_rtx
;
1823 else if (structure_value_addr
)
1825 if (target
== 0 || GET_CODE (target
) != MEM
)
1827 target
= gen_rtx (MEM
, TYPE_MODE (TREE_TYPE (exp
)),
1828 memory_address (TYPE_MODE (TREE_TYPE (exp
)),
1829 structure_value_addr
));
1830 MEM_IN_STRUCT_P (target
)
1831 = (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
1832 || TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
1833 || TREE_CODE (TREE_TYPE (exp
)) == UNION_TYPE
1834 || TREE_CODE (TREE_TYPE (exp
)) == QUAL_UNION_TYPE
);
1837 else if (pcc_struct_value
)
1841 target
= gen_rtx (MEM
, TYPE_MODE (TREE_TYPE (exp
)),
1842 copy_to_reg (valreg
));
1843 MEM_IN_STRUCT_P (target
)
1844 = (TREE_CODE (TREE_TYPE (exp
)) == ARRAY_TYPE
1845 || TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
1846 || TREE_CODE (TREE_TYPE (exp
)) == UNION_TYPE
1847 || TREE_CODE (TREE_TYPE (exp
)) == QUAL_UNION_TYPE
);
1849 else if (TYPE_MODE (TREE_TYPE (exp
)) != BLKmode
)
1850 emit_move_insn (target
, gen_rtx (MEM
, TYPE_MODE (TREE_TYPE (exp
)),
1851 copy_to_reg (valreg
)));
1853 emit_block_move (target
, gen_rtx (MEM
, BLKmode
, copy_to_reg (valreg
)),
1855 TYPE_ALIGN (TREE_TYPE (exp
)) / BITS_PER_UNIT
);
1857 else if (target
&& GET_MODE (target
) == TYPE_MODE (TREE_TYPE (exp
))
1858 && GET_MODE (target
) == GET_MODE (valreg
))
1859 /* TARGET and VALREG cannot be equal at this point because the latter
1860 would not have REG_FUNCTION_VALUE_P true, while the former would if
1861 it were referring to the same register.
1863 If they refer to the same register, this move will be a no-op, except
1864 when function inlining is being done. */
1865 emit_move_insn (target
, valreg
);
1867 target
= copy_to_reg (valreg
);
1869 #ifdef PROMOTE_FUNCTION_RETURN
1870 /* If we promoted this return value, make the proper SUBREG. TARGET
1871 might be const0_rtx here, so be careful. */
1872 if (GET_CODE (target
) == REG
1873 && GET_MODE (target
) != TYPE_MODE (TREE_TYPE (exp
)))
1875 enum machine_mode mode
= TYPE_MODE (TREE_TYPE (exp
));
1876 int unsignedp
= TREE_UNSIGNED (TREE_TYPE (exp
));
1878 if (TREE_CODE (TREE_TYPE (exp
)) == INTEGER_TYPE
1879 || TREE_CODE (TREE_TYPE (exp
)) == ENUMERAL_TYPE
1880 || TREE_CODE (TREE_TYPE (exp
)) == BOOLEAN_TYPE
1881 || TREE_CODE (TREE_TYPE (exp
)) == CHAR_TYPE
1882 || TREE_CODE (TREE_TYPE (exp
)) == REAL_TYPE
1883 || TREE_CODE (TREE_TYPE (exp
)) == POINTER_TYPE
1884 || TREE_CODE (TREE_TYPE (exp
)) == OFFSET_TYPE
)
1886 PROMOTE_MODE (mode
, unsignedp
, TREE_TYPE (exp
));
1889 /* If we didn't promote as expected, something is wrong. */
1890 if (mode
!= GET_MODE (target
))
1893 target
= gen_rtx (SUBREG
, TYPE_MODE (TREE_TYPE (exp
)), target
, 0);
1894 SUBREG_PROMOTED_VAR_P (target
) = 1;
1895 SUBREG_PROMOTED_UNSIGNED_P (target
) = unsignedp
;
1899 /* Perform all cleanups needed for the arguments of this call
1900 (i.e. destructors in C++). */
1901 expand_cleanups_to (old_cleanups
);
1903 /* If size of args is variable or this was a constructor call for a stack
1904 argument, restore saved stack-pointer value. */
1906 if (old_stack_level
)
1908 emit_stack_restore (SAVE_BLOCK
, old_stack_level
, NULL_RTX
);
1909 pending_stack_adjust
= old_pending_adj
;
1910 #ifdef ACCUMULATE_OUTGOING_ARGS
1911 stack_arg_under_construction
= old_stack_arg_under_construction
;
1912 highest_outgoing_arg_in_use
= initial_highest_arg_in_use
;
1913 stack_usage_map
= initial_stack_usage_map
;
1916 #ifdef ACCUMULATE_OUTGOING_ARGS
1919 #ifdef REG_PARM_STACK_SPACE
1922 enum machine_mode save_mode
= GET_MODE (save_area
);
1924 = gen_rtx (MEM
, save_mode
,
1925 memory_address (save_mode
,
1926 #ifdef ARGS_GROW_DOWNWARD
1927 plus_constant (argblock
, - high_to_save
)
1929 plus_constant (argblock
, low_to_save
)
1933 if (save_mode
!= BLKmode
)
1934 emit_move_insn (stack_area
, save_area
);
1936 emit_block_move (stack_area
, validize_mem (save_area
),
1937 GEN_INT (high_to_save
- low_to_save
+ 1),
1938 PARM_BOUNDARY
/ BITS_PER_UNIT
);
1942 /* If we saved any argument areas, restore them. */
1943 for (i
= 0; i
< num_actuals
; i
++)
1944 if (args
[i
].save_area
)
1946 enum machine_mode save_mode
= GET_MODE (args
[i
].save_area
);
1948 = gen_rtx (MEM
, save_mode
,
1949 memory_address (save_mode
,
1950 XEXP (args
[i
].stack_slot
, 0)));
1952 if (save_mode
!= BLKmode
)
1953 emit_move_insn (stack_area
, args
[i
].save_area
);
1955 emit_block_move (stack_area
, validize_mem (args
[i
].save_area
),
1956 GEN_INT (args
[i
].size
.constant
),
1957 PARM_BOUNDARY
/ BITS_PER_UNIT
);
1960 highest_outgoing_arg_in_use
= initial_highest_arg_in_use
;
1961 stack_usage_map
= initial_stack_usage_map
;
1965 /* If this was alloca, record the new stack level for nonlocal gotos.
1966 Check for the handler slots since we might not have a save area
1967 for non-local gotos. */
1969 if (may_be_alloca
&& nonlocal_goto_handler_slot
!= 0)
1970 emit_stack_save (SAVE_NONLOCAL
, &nonlocal_goto_stack_level
, NULL_RTX
);
1977 /* Output a library call to function FUN (a SYMBOL_REF rtx)
1978 (emitting the queue unless NO_QUEUE is nonzero),
1979 for a value of mode OUTMODE,
1980 with NARGS different arguments, passed as alternating rtx values
1981 and machine_modes to convert them to.
1982 The rtx values should have been passed through protect_from_queue already.
1984 NO_QUEUE will be true if and only if the library call is a `const' call
1985 which will be enclosed in REG_LIBCALL/REG_RETVAL notes; it is equivalent
1986 to the variable is_const in expand_call.
1988 NO_QUEUE must be true for const calls, because if it isn't, then
1989 any pending increment will be emitted between REG_LIBCALL/REG_RETVAL notes,
1990 and will be lost if the libcall sequence is optimized away.
1992 NO_QUEUE must be false for non-const calls, because if it isn't, the
1993 call insn will have its CONST_CALL_P bit set, and it will be incorrectly
1994 optimized. For instance, the instruction scheduler may incorrectly
1995 move memory references across the non-const call. */
1998 emit_library_call (va_alist
)
2002 /* Total size in bytes of all the stack-parms scanned so far. */
2003 struct args_size args_size
;
2004 /* Size of arguments before any adjustments (such as rounding). */
2005 struct args_size original_args_size
;
2006 register int argnum
;
2007 enum machine_mode outmode
;
2014 CUMULATIVE_ARGS args_so_far
;
2015 struct arg
{ rtx value
; enum machine_mode mode
; rtx reg
; int partial
;
2016 struct args_size offset
; struct args_size size
; };
2018 int old_inhibit_defer_pop
= inhibit_defer_pop
;
2021 /* library calls are never indirect calls. */
2022 int current_call_is_indirect
= 0;
2025 orgfun
= fun
= va_arg (p
, rtx
);
2026 no_queue
= va_arg (p
, int);
2027 outmode
= va_arg (p
, enum machine_mode
);
2028 nargs
= va_arg (p
, int);
2030 /* Copy all the libcall-arguments out of the varargs data
2031 and into a vector ARGVEC.
2033 Compute how to pass each argument. We only support a very small subset
2034 of the full argument passing conventions to limit complexity here since
2035 library functions shouldn't have many args. */
2037 argvec
= (struct arg
*) alloca (nargs
* sizeof (struct arg
));
2039 INIT_CUMULATIVE_ARGS (args_so_far
, NULL_TREE
, fun
);
2041 args_size
.constant
= 0;
2044 for (count
= 0; count
< nargs
; count
++)
2046 rtx val
= va_arg (p
, rtx
);
2047 enum machine_mode mode
= va_arg (p
, enum machine_mode
);
2049 /* We cannot convert the arg value to the mode the library wants here;
2050 must do it earlier where we know the signedness of the arg. */
2052 || (GET_MODE (val
) != mode
&& GET_MODE (val
) != VOIDmode
))
2055 /* On some machines, there's no way to pass a float to a library fcn.
2056 Pass it as a double instead. */
2057 #ifdef LIBGCC_NEEDS_DOUBLE
2058 if (LIBGCC_NEEDS_DOUBLE
&& mode
== SFmode
)
2059 val
= convert_to_mode (DFmode
, val
, 0), mode
= DFmode
;
2062 /* There's no need to call protect_from_queue, because
2063 either emit_move_insn or emit_push_insn will do that. */
2065 /* Make sure it is a reasonable operand for a move or push insn. */
2066 if (GET_CODE (val
) != REG
&& GET_CODE (val
) != MEM
2067 && ! (CONSTANT_P (val
) && LEGITIMATE_CONSTANT_P (val
)))
2068 val
= force_operand (val
, NULL_RTX
);
2070 argvec
[count
].value
= val
;
2071 argvec
[count
].mode
= mode
;
2073 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
2074 if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far
, mode
, NULL_TREE
, 1))
2078 argvec
[count
].reg
= FUNCTION_ARG (args_so_far
, mode
, NULL_TREE
, 1);
2079 if (argvec
[count
].reg
&& GET_CODE (argvec
[count
].reg
) == EXPR_LIST
)
2081 #ifdef FUNCTION_ARG_PARTIAL_NREGS
2082 argvec
[count
].partial
2083 = FUNCTION_ARG_PARTIAL_NREGS (args_so_far
, mode
, NULL_TREE
, 1);
2085 argvec
[count
].partial
= 0;
2088 locate_and_pad_parm (mode
, NULL_TREE
,
2089 argvec
[count
].reg
&& argvec
[count
].partial
== 0,
2090 NULL_TREE
, &args_size
, &argvec
[count
].offset
,
2091 &argvec
[count
].size
);
2093 if (argvec
[count
].size
.var
)
2096 #ifndef REG_PARM_STACK_SPACE
2097 if (argvec
[count
].partial
)
2098 argvec
[count
].size
.constant
-= argvec
[count
].partial
* UNITS_PER_WORD
;
2101 if (argvec
[count
].reg
== 0 || argvec
[count
].partial
!= 0
2102 #ifdef REG_PARM_STACK_SPACE
2106 args_size
.constant
+= argvec
[count
].size
.constant
;
2108 #ifdef ACCUMULATE_OUTGOING_ARGS
2109 /* If this arg is actually passed on the stack, it might be
2110 clobbering something we already put there (this library call might
2111 be inside the evaluation of an argument to a function whose call
2112 requires the stack). This will only occur when the library call
2113 has sufficient args to run out of argument registers. Abort in
2114 this case; if this ever occurs, code must be added to save and
2115 restore the arg slot. */
2117 if (argvec
[count
].reg
== 0 || argvec
[count
].partial
!= 0)
2121 FUNCTION_ARG_ADVANCE (args_so_far
, mode
, (tree
)0, 1);
2125 /* If this machine requires an external definition for library
2126 functions, write one out. */
2127 assemble_external_libcall (fun
);
2129 original_args_size
= args_size
;
2130 #ifdef STACK_BOUNDARY
2131 args_size
.constant
= (((args_size
.constant
+ (STACK_BYTES
- 1))
2132 / STACK_BYTES
) * STACK_BYTES
);
2135 #ifdef REG_PARM_STACK_SPACE
2136 args_size
.constant
= MAX (args_size
.constant
,
2137 REG_PARM_STACK_SPACE (NULL_TREE
));
2138 #ifndef OUTGOING_REG_PARM_STACK_SPACE
2139 args_size
.constant
-= REG_PARM_STACK_SPACE (NULL_TREE
);
2143 #ifdef ACCUMULATE_OUTGOING_ARGS
2144 if (args_size
.constant
> current_function_outgoing_args_size
)
2145 current_function_outgoing_args_size
= args_size
.constant
;
2146 args_size
.constant
= 0;
2149 #ifndef PUSH_ROUNDING
2150 argblock
= push_block (GEN_INT (args_size
.constant
), 0, 0);
2153 #ifdef PUSH_ARGS_REVERSED
2154 #ifdef STACK_BOUNDARY
2155 /* If we push args individually in reverse order, perform stack alignment
2156 before the first push (the last arg). */
2158 anti_adjust_stack (GEN_INT (args_size
.constant
2159 - original_args_size
.constant
));
2163 #ifdef PUSH_ARGS_REVERSED
2171 /* Push the args that need to be pushed. */
2173 for (count
= 0; count
< nargs
; count
++, argnum
+= inc
)
2175 register enum machine_mode mode
= argvec
[argnum
].mode
;
2176 register rtx val
= argvec
[argnum
].value
;
2177 rtx reg
= argvec
[argnum
].reg
;
2178 int partial
= argvec
[argnum
].partial
;
2180 if (! (reg
!= 0 && partial
== 0))
2181 emit_push_insn (val
, mode
, NULL_TREE
, NULL_RTX
, 0, partial
, reg
, 0,
2182 argblock
, GEN_INT (argvec
[count
].offset
.constant
));
2186 #ifndef PUSH_ARGS_REVERSED
2187 #ifdef STACK_BOUNDARY
2188 /* If we pushed args in forward order, perform stack alignment
2189 after pushing the last arg. */
2191 anti_adjust_stack (GEN_INT (args_size
.constant
2192 - original_args_size
.constant
));
2196 #ifdef PUSH_ARGS_REVERSED
2202 /* Now load any reg parms into their regs. */
2204 for (count
= 0; count
< nargs
; count
++, argnum
+= inc
)
2206 register enum machine_mode mode
= argvec
[argnum
].mode
;
2207 register rtx val
= argvec
[argnum
].value
;
2208 rtx reg
= argvec
[argnum
].reg
;
2209 int partial
= argvec
[argnum
].partial
;
2211 if (reg
!= 0 && partial
== 0)
2212 emit_move_insn (reg
, val
);
2216 /* For version 1.37, try deleting this entirely. */
2220 /* Any regs containing parms remain in use through the call. */
2222 for (count
= 0; count
< nargs
; count
++)
2223 if (argvec
[count
].reg
!= 0)
2224 emit_insn (gen_rtx (USE
, VOIDmode
, argvec
[count
].reg
));
2226 use_insns
= get_insns ();
2229 fun
= prepare_call_address (fun
, NULL_TREE
, &use_insns
);
2231 /* Don't allow popping to be deferred, since then
2232 cse'ing of library calls could delete a call and leave the pop. */
2235 /* We pass the old value of inhibit_defer_pop + 1 to emit_call_1, which
2236 will set inhibit_defer_pop to that value. */
2238 emit_call_1 (fun
, get_identifier (XSTR (orgfun
, 0)), args_size
.constant
, 0,
2239 FUNCTION_ARG (args_so_far
, VOIDmode
, void_type_node
, 1),
2240 outmode
!= VOIDmode
? hard_libcall_value (outmode
) : NULL_RTX
,
2241 old_inhibit_defer_pop
+ 1, use_insns
, no_queue
);
2243 /* Now restore inhibit_defer_pop to its actual original value. */
2247 /* Like emit_library_call except that an extra argument, VALUE,
2248 comes second and says where to store the result.
2249 (If VALUE is zero, the result comes in the function value register.) */
2252 emit_library_call_value (va_alist
)
2256 /* Total size in bytes of all the stack-parms scanned so far. */
2257 struct args_size args_size
;
2258 /* Size of arguments before any adjustments (such as rounding). */
2259 struct args_size original_args_size
;
2260 register int argnum
;
2261 enum machine_mode outmode
;
2268 CUMULATIVE_ARGS args_so_far
;
2269 struct arg
{ rtx value
; enum machine_mode mode
; rtx reg
; int partial
;
2270 struct args_size offset
; struct args_size size
; };
2272 int old_inhibit_defer_pop
= inhibit_defer_pop
;
2277 /* library calls are never indirect calls. */
2278 int current_call_is_indirect
= 0;
2281 orgfun
= fun
= va_arg (p
, rtx
);
2282 value
= va_arg (p
, rtx
);
2283 no_queue
= va_arg (p
, int);
2284 outmode
= va_arg (p
, enum machine_mode
);
2285 nargs
= va_arg (p
, int);
2287 /* If this kind of value comes back in memory,
2288 decide where in memory it should come back. */
2289 if (RETURN_IN_MEMORY (type_for_mode (outmode
, 0)))
2291 if (GET_CODE (value
) == MEM
)
2294 mem_value
= assign_stack_temp (outmode
, GET_MODE_SIZE (outmode
), 0);
2297 /* ??? Unfinished: must pass the memory address as an argument. */
2299 /* Copy all the libcall-arguments out of the varargs data
2300 and into a vector ARGVEC.
2302 Compute how to pass each argument. We only support a very small subset
2303 of the full argument passing conventions to limit complexity here since
2304 library functions shouldn't have many args. */
2306 argvec
= (struct arg
*) alloca ((nargs
+ 1) * sizeof (struct arg
));
2308 INIT_CUMULATIVE_ARGS (args_so_far
, NULL_TREE
, fun
);
2310 args_size
.constant
= 0;
2315 /* If there's a structure value address to be passed,
2316 either pass it in the special place, or pass it as an extra argument. */
2319 rtx addr
= XEXP (mem_value
, 0);
2321 if (! struct_value_rtx
)
2325 /* Make sure it is a reasonable operand for a move or push insn. */
2326 if (GET_CODE (addr
) != REG
&& GET_CODE (addr
) != MEM
2327 && ! (CONSTANT_P (addr
) && LEGITIMATE_CONSTANT_P (addr
)))
2328 addr
= force_operand (addr
, NULL_RTX
);
2330 argvec
[count
].value
= addr
;
2331 argvec
[count
].mode
= outmode
;
2332 argvec
[count
].partial
= 0;
2334 argvec
[count
].reg
= FUNCTION_ARG (args_so_far
, outmode
, NULL_TREE
, 1);
2335 #ifdef FUNCTION_ARG_PARTIAL_NREGS
2336 if (FUNCTION_ARG_PARTIAL_NREGS (args_so_far
, outmode
, NULL_TREE
, 1))
2340 locate_and_pad_parm (outmode
, NULL_TREE
,
2341 argvec
[count
].reg
&& argvec
[count
].partial
== 0,
2342 NULL_TREE
, &args_size
, &argvec
[count
].offset
,
2343 &argvec
[count
].size
);
2346 if (argvec
[count
].reg
== 0 || argvec
[count
].partial
!= 0
2347 #ifdef REG_PARM_STACK_SPACE
2351 args_size
.constant
+= argvec
[count
].size
.constant
;
2353 FUNCTION_ARG_ADVANCE (args_so_far
, outmode
, (tree
)0, 1);
2357 for (; count
< nargs
; count
++)
2359 rtx val
= va_arg (p
, rtx
);
2360 enum machine_mode mode
= va_arg (p
, enum machine_mode
);
2362 /* We cannot convert the arg value to the mode the library wants here;
2363 must do it earlier where we know the signedness of the arg. */
2365 || (GET_MODE (val
) != mode
&& GET_MODE (val
) != VOIDmode
))
2368 /* On some machines, there's no way to pass a float to a library fcn.
2369 Pass it as a double instead. */
2370 #ifdef LIBGCC_NEEDS_DOUBLE
2371 if (LIBGCC_NEEDS_DOUBLE
&& mode
== SFmode
)
2372 val
= convert_to_mode (DFmode
, val
, 0), mode
= DFmode
;
2375 /* There's no need to call protect_from_queue, because
2376 either emit_move_insn or emit_push_insn will do that. */
2378 /* Make sure it is a reasonable operand for a move or push insn. */
2379 if (GET_CODE (val
) != REG
&& GET_CODE (val
) != MEM
2380 && ! (CONSTANT_P (val
) && LEGITIMATE_CONSTANT_P (val
)))
2381 val
= force_operand (val
, NULL_RTX
);
2383 argvec
[count
].value
= val
;
2384 argvec
[count
].mode
= mode
;
2386 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
2387 if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far
, mode
, NULL_TREE
, 1))
2391 argvec
[count
].reg
= FUNCTION_ARG (args_so_far
, mode
, NULL_TREE
, 1);
2392 if (argvec
[count
].reg
&& GET_CODE (argvec
[count
].reg
) == EXPR_LIST
)
2394 #ifdef FUNCTION_ARG_PARTIAL_NREGS
2395 argvec
[count
].partial
2396 = FUNCTION_ARG_PARTIAL_NREGS (args_so_far
, mode
, NULL_TREE
, 1);
2398 argvec
[count
].partial
= 0;
2401 locate_and_pad_parm (mode
, NULL_TREE
,
2402 argvec
[count
].reg
&& argvec
[count
].partial
== 0,
2403 NULL_TREE
, &args_size
, &argvec
[count
].offset
,
2404 &argvec
[count
].size
);
2406 if (argvec
[count
].size
.var
)
2409 #ifndef REG_PARM_STACK_SPACE
2410 if (argvec
[count
].partial
)
2411 argvec
[count
].size
.constant
-= argvec
[count
].partial
* UNITS_PER_WORD
;
2414 if (argvec
[count
].reg
== 0 || argvec
[count
].partial
!= 0
2415 #ifdef REG_PARM_STACK_SPACE
2419 args_size
.constant
+= argvec
[count
].size
.constant
;
2421 #ifdef ACCUMULATE_OUTGOING_ARGS
2422 /* If this arg is actually passed on the stack, it might be
2423 clobbering something we already put there (this library call might
2424 be inside the evaluation of an argument to a function whose call
2425 requires the stack). This will only occur when the library call
2426 has sufficient args to run out of argument registers. Abort in
2427 this case; if this ever occurs, code must be added to save and
2428 restore the arg slot. */
2430 if (argvec
[count
].reg
== 0 || argvec
[count
].partial
!= 0)
2434 FUNCTION_ARG_ADVANCE (args_so_far
, mode
, (tree
)0, 1);
2438 /* If this machine requires an external definition for library
2439 functions, write one out. */
2440 assemble_external_libcall (fun
);
2442 original_args_size
= args_size
;
2443 #ifdef STACK_BOUNDARY
2444 args_size
.constant
= (((args_size
.constant
+ (STACK_BYTES
- 1))
2445 / STACK_BYTES
) * STACK_BYTES
);
2448 #ifdef REG_PARM_STACK_SPACE
2449 args_size
.constant
= MAX (args_size
.constant
,
2450 REG_PARM_STACK_SPACE (NULL_TREE
));
2451 #ifndef OUTGOING_REG_PARM_STACK_SPACE
2452 args_size
.constant
-= REG_PARM_STACK_SPACE (NULL_TREE
);
2456 #ifdef ACCUMULATE_OUTGOING_ARGS
2457 if (args_size
.constant
> current_function_outgoing_args_size
)
2458 current_function_outgoing_args_size
= args_size
.constant
;
2459 args_size
.constant
= 0;
2462 #ifndef PUSH_ROUNDING
2463 argblock
= push_block (GEN_INT (args_size
.constant
), 0, 0);
2466 #ifdef PUSH_ARGS_REVERSED
2467 #ifdef STACK_BOUNDARY
2468 /* If we push args individually in reverse order, perform stack alignment
2469 before the first push (the last arg). */
2471 anti_adjust_stack (GEN_INT (args_size
.constant
2472 - original_args_size
.constant
));
2476 #ifdef PUSH_ARGS_REVERSED
2484 /* Push the args that need to be pushed. */
2486 for (count
= 0; count
< nargs
; count
++, argnum
+= inc
)
2488 register enum machine_mode mode
= argvec
[argnum
].mode
;
2489 register rtx val
= argvec
[argnum
].value
;
2490 rtx reg
= argvec
[argnum
].reg
;
2491 int partial
= argvec
[argnum
].partial
;
2493 if (! (reg
!= 0 && partial
== 0))
2494 emit_push_insn (val
, mode
, NULL_TREE
, NULL_RTX
, 0, partial
, reg
, 0,
2495 argblock
, GEN_INT (argvec
[count
].offset
.constant
));
2499 #ifndef PUSH_ARGS_REVERSED
2500 #ifdef STACK_BOUNDARY
2501 /* If we pushed args in forward order, perform stack alignment
2502 after pushing the last arg. */
2504 anti_adjust_stack (GEN_INT (args_size
.constant
2505 - original_args_size
.constant
));
2509 #ifdef PUSH_ARGS_REVERSED
2515 /* Now load any reg parms into their regs. */
2517 if (mem_value
!= 0 && struct_value_rtx
!= 0)
2518 emit_move_insn (struct_value_rtx
, XEXP (mem_value
, 0));
2520 for (count
= 0; count
< nargs
; count
++, argnum
+= inc
)
2522 register enum machine_mode mode
= argvec
[argnum
].mode
;
2523 register rtx val
= argvec
[argnum
].value
;
2524 rtx reg
= argvec
[argnum
].reg
;
2525 int partial
= argvec
[argnum
].partial
;
2527 if (reg
!= 0 && partial
== 0)
2528 emit_move_insn (reg
, val
);
2533 /* For version 1.37, try deleting this entirely. */
2538 /* Any regs containing parms remain in use through the call. */
2540 for (count
= 0; count
< nargs
; count
++)
2541 if (argvec
[count
].reg
!= 0)
2542 emit_insn (gen_rtx (USE
, VOIDmode
, argvec
[count
].reg
));
2544 use_insns
= get_insns ();
2547 fun
= prepare_call_address (fun
, NULL_TREE
, &use_insns
);
2549 /* Don't allow popping to be deferred, since then
2550 cse'ing of library calls could delete a call and leave the pop. */
2553 /* We pass the old value of inhibit_defer_pop + 1 to emit_call_1, which
2554 will set inhibit_defer_pop to that value. */
2556 emit_call_1 (fun
, get_identifier (XSTR (orgfun
, 0)), args_size
.constant
, 0,
2557 FUNCTION_ARG (args_so_far
, VOIDmode
, void_type_node
, 1),
2558 outmode
!= VOIDmode
? hard_libcall_value (outmode
) : NULL_RTX
,
2559 old_inhibit_defer_pop
+ 1, use_insns
, no_queue
);
2561 /* Now restore inhibit_defer_pop to its actual original value. */
2564 /* Copy the value to the right place. */
2565 if (outmode
!= VOIDmode
)
2570 value
= hard_libcall_value (outmode
);
2571 if (value
!= mem_value
)
2572 emit_move_insn (value
, mem_value
);
2574 else if (value
!= 0)
2575 emit_move_insn (value
, hard_libcall_value (outmode
));
2580 /* Return an rtx which represents a suitable home on the stack
2581 given TYPE, the type of the argument looking for a home.
2582 This is called only for BLKmode arguments.
2584 SIZE is the size needed for this target.
2585 ARGS_ADDR is the address of the bottom of the argument block for this call.
2586 OFFSET describes this parameter's offset into ARGS_ADDR. It is meaningless
2587 if this machine uses push insns. */
2590 target_for_arg (type
, size
, args_addr
, offset
)
2594 struct args_size offset
;
2597 rtx offset_rtx
= ARGS_SIZE_RTX (offset
);
2599 /* We do not call memory_address if possible,
2600 because we want to address as close to the stack
2601 as possible. For non-variable sized arguments,
2602 this will be stack-pointer relative addressing. */
2603 if (GET_CODE (offset_rtx
) == CONST_INT
)
2604 target
= plus_constant (args_addr
, INTVAL (offset_rtx
));
2607 /* I have no idea how to guarantee that this
2608 will work in the presence of register parameters. */
2609 target
= gen_rtx (PLUS
, Pmode
, args_addr
, offset_rtx
);
2610 target
= memory_address (QImode
, target
);
2613 return gen_rtx (MEM
, BLKmode
, target
);
2617 /* Store a single argument for a function call
2618 into the register or memory area where it must be passed.
2619 *ARG describes the argument value and where to pass it.
2621 ARGBLOCK is the address of the stack-block for all the arguments,
2622 or 0 on a machine where arguments are pushed individually.
2624 MAY_BE_ALLOCA nonzero says this could be a call to `alloca'
2625 so must be careful about how the stack is used.
2627 VARIABLE_SIZE nonzero says that this was a variable-sized outgoing
2628 argument stack. This is used if ACCUMULATE_OUTGOING_ARGS to indicate
2629 that we need not worry about saving and restoring the stack.
2631 FNDECL is the declaration of the function we are calling. */
2634 store_one_arg (arg
, argblock
, may_be_alloca
, variable_size
, fndecl
,
2635 reg_parm_stack_space
)
2636 struct arg_data
*arg
;
2641 int reg_parm_stack_space
;
2643 register tree pval
= arg
->tree_value
;
2647 int i
, lower_bound
, upper_bound
;
2649 if (TREE_CODE (pval
) == ERROR_MARK
)
2652 #ifdef ACCUMULATE_OUTGOING_ARGS
2653 /* If this is being stored into a pre-allocated, fixed-size, stack area,
2654 save any previous data at that location. */
2655 if (argblock
&& ! variable_size
&& arg
->stack
)
2657 #ifdef ARGS_GROW_DOWNWARD
2658 /* stack_slot is negative, but we want to index stack_usage_map */
2659 /* with positive values. */
2660 if (GET_CODE (XEXP (arg
->stack_slot
, 0)) == PLUS
)
2661 upper_bound
= -INTVAL (XEXP (XEXP (arg
->stack_slot
, 0), 1)) + 1;
2665 lower_bound
= upper_bound
- arg
->size
.constant
;
2667 if (GET_CODE (XEXP (arg
->stack_slot
, 0)) == PLUS
)
2668 lower_bound
= INTVAL (XEXP (XEXP (arg
->stack_slot
, 0), 1));
2672 upper_bound
= lower_bound
+ arg
->size
.constant
;
2675 for (i
= lower_bound
; i
< upper_bound
; i
++)
2676 if (stack_usage_map
[i
]
2677 #ifdef REG_PARM_STACK_SPACE
2678 /* Don't store things in the fixed argument area at this point;
2679 it has already been saved. */
2680 && i
> reg_parm_stack_space
2685 if (i
!= upper_bound
)
2687 /* We need to make a save area. See what mode we can make it. */
2688 enum machine_mode save_mode
2689 = mode_for_size (arg
->size
.constant
* BITS_PER_UNIT
, MODE_INT
, 1);
2691 = gen_rtx (MEM
, save_mode
,
2692 memory_address (save_mode
, XEXP (arg
->stack_slot
, 0)));
2694 if (save_mode
== BLKmode
)
2696 arg
->save_area
= assign_stack_temp (BLKmode
,
2697 arg
->size
.constant
, 1);
2698 emit_block_move (validize_mem (arg
->save_area
), stack_area
,
2699 GEN_INT (arg
->size
.constant
),
2700 PARM_BOUNDARY
/ BITS_PER_UNIT
);
2704 arg
->save_area
= gen_reg_rtx (save_mode
);
2705 emit_move_insn (arg
->save_area
, stack_area
);
2711 /* If this isn't going to be placed on both the stack and in registers,
2712 set up the register and number of words. */
2713 if (! arg
->pass_on_stack
)
2714 reg
= arg
->reg
, partial
= arg
->partial
;
2716 if (reg
!= 0 && partial
== 0)
2717 /* Being passed entirely in a register. We shouldn't be called in
2721 #ifdef STRICT_ALIGNMENT
2722 /* If this arg needs special alignment, don't load the registers
2724 if (arg
->n_aligned_regs
!= 0)
2728 /* If this is being partially passed in a register, but multiple locations
2729 are specified, we assume that the one partially used is the one that is
2731 if (reg
&& GET_CODE (reg
) == EXPR_LIST
)
2732 reg
= XEXP (reg
, 0);
2734 /* If this is being passed partially in a register, we can't evaluate
2735 it directly into its stack slot. Otherwise, we can. */
2736 if (arg
->value
== 0)
2738 #ifdef ACCUMULATE_OUTGOING_ARGS
2739 /* stack_arg_under_construction is nonzero if a function argument is
2740 being evaluated directly into the outgoing argument list and
2741 expand_call must take special action to preserve the argument list
2742 if it is called recursively.
2744 For scalar function arguments stack_usage_map is sufficient to
2745 determine which stack slots must be saved and restored. Scalar
2746 arguments in general have pass_on_stack == 0.
2748 If this argument is initialized by a function which takes the
2749 address of the argument (a C++ constructor or a C function
2750 returning a BLKmode structure), then stack_usage_map is
2751 insufficient and expand_call must push the stack around the
2752 function call. Such arguments have pass_on_stack == 1.
2754 Note that it is always safe to set stack_arg_under_construction,
2755 but this generates suboptimal code if set when not needed. */
2757 if (arg
->pass_on_stack
)
2758 stack_arg_under_construction
++;
2760 arg
->value
= expand_expr (pval
, partial
? NULL_RTX
: arg
->stack
,
2763 /* If we are promoting object (or for any other reason) the mode
2764 doesn't agree, convert the mode. */
2766 if (GET_MODE (arg
->value
) != VOIDmode
2767 && GET_MODE (arg
->value
) != arg
->mode
)
2768 arg
->value
= convert_to_mode (arg
->mode
, arg
->value
, arg
->unsignedp
);
2770 #ifdef ACCUMULATE_OUTGOING_ARGS
2771 if (arg
->pass_on_stack
)
2772 stack_arg_under_construction
--;
2776 /* Don't allow anything left on stack from computation
2777 of argument to alloca. */
2779 do_pending_stack_adjust ();
2781 if (arg
->value
== arg
->stack
)
2782 /* If the value is already in the stack slot, we are done. */
2784 else if (arg
->mode
!= BLKmode
)
2788 /* Argument is a scalar, not entirely passed in registers.
2789 (If part is passed in registers, arg->partial says how much
2790 and emit_push_insn will take care of putting it there.)
2792 Push it, and if its size is less than the
2793 amount of space allocated to it,
2794 also bump stack pointer by the additional space.
2795 Note that in C the default argument promotions
2796 will prevent such mismatches. */
2798 size
= GET_MODE_SIZE (arg
->mode
);
2799 /* Compute how much space the push instruction will push.
2800 On many machines, pushing a byte will advance the stack
2801 pointer by a halfword. */
2802 #ifdef PUSH_ROUNDING
2803 size
= PUSH_ROUNDING (size
);
2807 /* Compute how much space the argument should get:
2808 round up to a multiple of the alignment for arguments. */
2809 if (none
!= FUNCTION_ARG_PADDING (arg
->mode
, TREE_TYPE (pval
)))
2810 used
= (((size
+ PARM_BOUNDARY
/ BITS_PER_UNIT
- 1)
2811 / (PARM_BOUNDARY
/ BITS_PER_UNIT
))
2812 * (PARM_BOUNDARY
/ BITS_PER_UNIT
));
2814 /* This isn't already where we want it on the stack, so put it there.
2815 This can either be done with push or copy insns. */
2816 emit_push_insn (arg
->value
, arg
->mode
, TREE_TYPE (pval
), NULL_RTX
,
2817 0, partial
, reg
, used
- size
,
2818 argblock
, ARGS_SIZE_RTX (arg
->offset
));
2822 /* BLKmode, at least partly to be pushed. */
2824 register int excess
;
2827 /* Pushing a nonscalar.
2828 If part is passed in registers, PARTIAL says how much
2829 and emit_push_insn will take care of putting it there. */
2831 /* Round its size up to a multiple
2832 of the allocation unit for arguments. */
2834 if (arg
->size
.var
!= 0)
2837 size_rtx
= ARGS_SIZE_RTX (arg
->size
);
2841 /* PUSH_ROUNDING has no effect on us, because
2842 emit_push_insn for BLKmode is careful to avoid it. */
2843 excess
= (arg
->size
.constant
- int_size_in_bytes (TREE_TYPE (pval
))
2844 + partial
* UNITS_PER_WORD
);
2845 size_rtx
= expr_size (pval
);
2848 emit_push_insn (arg
->value
, arg
->mode
, TREE_TYPE (pval
), size_rtx
,
2849 TYPE_ALIGN (TREE_TYPE (pval
)) / BITS_PER_UNIT
, partial
,
2850 reg
, excess
, argblock
, ARGS_SIZE_RTX (arg
->offset
));
2854 /* Unless this is a partially-in-register argument, the argument is now
2857 ??? Note that this can change arg->value from arg->stack to
2858 arg->stack_slot and it matters when they are not the same.
2859 It isn't totally clear that this is correct in all cases. */
2861 arg
->value
= arg
->stack_slot
;
2863 /* Once we have pushed something, pops can't safely
2864 be deferred during the rest of the arguments. */
2867 /* ANSI doesn't require a sequence point here,
2868 but PCC has one, so this will avoid some problems. */
2871 /* Free any temporary slots made in processing this argument. */
2874 #ifdef ACCUMULATE_OUTGOING_ARGS
2875 /* Now mark the segment we just used. */
2876 if (argblock
&& ! variable_size
&& arg
->stack
)
2877 for (i
= lower_bound
; i
< upper_bound
; i
++)
2878 stack_usage_map
[i
] = 1;