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