* optimize.c (initialize_inlined_parameters): Take FN to which the
[official-gcc.git] / gcc / integrate.c
blobf8253095872b03e3b11a8ba053da96b30cb10440
1 /* Procedure integration for GNU CC.
2 Copyright (C) 1988, 91, 93-98, 1999 Free Software Foundation, Inc.
3 Contributed by Michael Tiemann (tiemann@cygnus.com)
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 #include "config.h"
24 #include "system.h"
26 #include "rtl.h"
27 #include "tree.h"
28 #include "tm_p.h"
29 #include "regs.h"
30 #include "flags.h"
31 #include "insn-config.h"
32 #include "insn-flags.h"
33 #include "expr.h"
34 #include "output.h"
35 #include "recog.h"
36 #include "integrate.h"
37 #include "real.h"
38 #include "except.h"
39 #include "function.h"
40 #include "toplev.h"
41 #include "intl.h"
42 #include "loop.h"
44 #include "obstack.h"
45 #define obstack_chunk_alloc xmalloc
46 #define obstack_chunk_free free
48 extern struct obstack *function_maybepermanent_obstack;
50 /* Similar, but round to the next highest integer that meets the
51 alignment. */
52 #define CEIL_ROUND(VALUE,ALIGN) (((VALUE) + (ALIGN) - 1) & ~((ALIGN)- 1))
54 /* Default max number of insns a function can have and still be inline.
55 This is overridden on RISC machines. */
56 #ifndef INTEGRATE_THRESHOLD
57 /* Inlining small functions might save more space then not inlining at
58 all. Assume 1 instruction for the call and 1.5 insns per argument. */
59 #define INTEGRATE_THRESHOLD(DECL) \
60 (optimize_size \
61 ? (1 + (3 * list_length (DECL_ARGUMENTS (DECL))) / 2) \
62 : (8 * (8 + list_length (DECL_ARGUMENTS (DECL)))))
63 #endif
65 static rtvec initialize_for_inline PROTO((tree));
66 static void note_modified_parmregs PROTO((rtx, rtx, void *));
67 static void integrate_parm_decls PROTO((tree, struct inline_remap *,
68 rtvec));
69 static tree integrate_decl_tree PROTO((tree,
70 struct inline_remap *));
71 static void subst_constants PROTO((rtx *, rtx,
72 struct inline_remap *, int));
73 static void set_block_origin_self PROTO((tree));
74 static void set_decl_origin_self PROTO((tree));
75 static void set_block_abstract_flags PROTO((tree, int));
76 static void process_reg_param PROTO((struct inline_remap *, rtx,
77 rtx));
78 void set_decl_abstract_flags PROTO((tree, int));
79 static rtx expand_inline_function_eh_labelmap PROTO((rtx));
80 static void mark_stores PROTO((rtx, rtx, void *));
82 /* The maximum number of instructions accepted for inlining a
83 function. Increasing values mean more agressive inlining.
84 This affects currently only functions explicitly marked as
85 inline (or methods defined within the class definition for C++).
86 The default value of 10000 is arbitrary but high to match the
87 previously unlimited gcc capabilities. */
89 int inline_max_insns = 10000;
91 /* Used by copy_rtx_and_substitute; this indicates whether the function is
92 called for the purpose of inlining or some other purpose (i.e. loop
93 unrolling). This affects how constant pool references are handled.
94 This variable contains the FUNCTION_DECL for the inlined function. */
95 static struct function *inlining = 0;
97 /* Returns the Ith entry in the label_map contained in MAP. If the
98 Ith entry has not yet been set, return a fresh label. This function
99 performs a lazy initialization of label_map, thereby avoiding huge memory
100 explosions when the label_map gets very large. */
103 get_label_from_map (map, i)
104 struct inline_remap *map;
105 int i;
107 rtx x = map->label_map[i];
109 if (x == NULL_RTX)
110 x = map->label_map[i] = gen_label_rtx();
112 return x;
115 /* Zero if the current function (whose FUNCTION_DECL is FNDECL)
116 is safe and reasonable to integrate into other functions.
117 Nonzero means value is a warning msgid with a single %s
118 for the function's name. */
120 const char *
121 function_cannot_inline_p (fndecl)
122 register tree fndecl;
124 register rtx insn;
125 tree last = tree_last (TYPE_ARG_TYPES (TREE_TYPE (fndecl)));
127 /* For functions marked as inline increase the maximum size to
128 inline_max_insns (-finline-limit-<n>). For regular functions
129 use the limit given by INTEGRATE_THRESHOLD. */
131 int max_insns = (DECL_INLINE (fndecl))
132 ? (inline_max_insns
133 + 8 * list_length (DECL_ARGUMENTS (fndecl)))
134 : INTEGRATE_THRESHOLD (fndecl);
136 register int ninsns = 0;
137 register tree parms;
138 rtx result;
140 /* No inlines with varargs. */
141 if ((last && TREE_VALUE (last) != void_type_node)
142 || current_function_varargs)
143 return N_("varargs function cannot be inline");
145 if (current_function_calls_alloca)
146 return N_("function using alloca cannot be inline");
148 if (current_function_calls_setjmp)
149 return N_("function using setjmp cannot be inline");
151 if (current_function_contains_functions)
152 return N_("function with nested functions cannot be inline");
154 if (forced_labels)
155 return
156 N_("function with label addresses used in initializers cannot inline");
158 if (current_function_cannot_inline)
159 return current_function_cannot_inline;
161 /* If its not even close, don't even look. */
162 if (get_max_uid () > 3 * max_insns)
163 return N_("function too large to be inline");
165 #if 0
166 /* Don't inline functions which do not specify a function prototype and
167 have BLKmode argument or take the address of a parameter. */
168 for (parms = DECL_ARGUMENTS (fndecl); parms; parms = TREE_CHAIN (parms))
170 if (TYPE_MODE (TREE_TYPE (parms)) == BLKmode)
171 TREE_ADDRESSABLE (parms) = 1;
172 if (last == NULL_TREE && TREE_ADDRESSABLE (parms))
173 return N_("no prototype, and parameter address used; cannot be inline");
175 #endif
177 /* We can't inline functions that return structures
178 the old-fashioned PCC way, copying into a static block. */
179 if (current_function_returns_pcc_struct)
180 return N_("inline functions not supported for this return value type");
182 /* We can't inline functions that return structures of varying size. */
183 if (int_size_in_bytes (TREE_TYPE (TREE_TYPE (fndecl))) < 0)
184 return N_("function with varying-size return value cannot be inline");
186 /* Cannot inline a function with a varying size argument or one that
187 receives a transparent union. */
188 for (parms = DECL_ARGUMENTS (fndecl); parms; parms = TREE_CHAIN (parms))
190 if (int_size_in_bytes (TREE_TYPE (parms)) < 0)
191 return N_("function with varying-size parameter cannot be inline");
192 else if (TYPE_TRANSPARENT_UNION (TREE_TYPE (parms)))
193 return N_("function with transparent unit parameter cannot be inline");
196 if (get_max_uid () > max_insns)
198 for (ninsns = 0, insn = get_first_nonparm_insn ();
199 insn && ninsns < max_insns;
200 insn = NEXT_INSN (insn))
201 if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
202 ninsns++;
204 if (ninsns >= max_insns)
205 return N_("function too large to be inline");
208 /* We will not inline a function which uses computed goto. The addresses of
209 its local labels, which may be tucked into global storage, are of course
210 not constant across instantiations, which causes unexpected behaviour. */
211 if (current_function_has_computed_jump)
212 return N_("function with computed jump cannot inline");
214 /* We cannot inline a nested function that jumps to a nonlocal label. */
215 if (current_function_has_nonlocal_goto)
216 return N_("function with nonlocal goto cannot be inline");
218 /* This is a hack, until the inliner is taught about eh regions at
219 the start of the function. */
220 for (insn = get_insns ();
221 insn
222 && ! (GET_CODE (insn) == NOTE
223 && NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_BEG);
224 insn = NEXT_INSN (insn))
226 if (insn && GET_CODE (insn) == NOTE
227 && NOTE_LINE_NUMBER (insn) == NOTE_INSN_EH_REGION_BEG)
228 return N_("function with complex parameters cannot be inline");
231 /* We can't inline functions that return a PARALLEL rtx. */
232 result = DECL_RTL (DECL_RESULT (fndecl));
233 if (result && GET_CODE (result) == PARALLEL)
234 return N_("inline functions not supported for this return value type");
236 return 0;
239 /* Map pseudo reg number into the PARM_DECL for the parm living in the reg.
240 Zero for a reg that isn't a parm's home.
241 Only reg numbers less than max_parm_reg are mapped here. */
242 static tree *parmdecl_map;
244 /* In save_for_inline, nonzero if past the parm-initialization insns. */
245 static int in_nonparm_insns;
247 /* Subroutine for `save_for_inline_nocopy'. Performs initialization
248 needed to save FNDECL's insns and info for future inline expansion. */
250 static rtvec
251 initialize_for_inline (fndecl)
252 tree fndecl;
254 int i;
255 rtvec arg_vector;
256 tree parms;
258 /* Clear out PARMDECL_MAP. It was allocated in the caller's frame. */
259 bzero ((char *) parmdecl_map, max_parm_reg * sizeof (tree));
260 arg_vector = rtvec_alloc (list_length (DECL_ARGUMENTS (fndecl)));
262 for (parms = DECL_ARGUMENTS (fndecl), i = 0;
263 parms;
264 parms = TREE_CHAIN (parms), i++)
266 rtx p = DECL_RTL (parms);
268 /* If we have (mem (addressof (mem ...))), use the inner MEM since
269 otherwise the copy_rtx call below will not unshare the MEM since
270 it shares ADDRESSOF. */
271 if (GET_CODE (p) == MEM && GET_CODE (XEXP (p, 0)) == ADDRESSOF
272 && GET_CODE (XEXP (XEXP (p, 0), 0)) == MEM)
273 p = XEXP (XEXP (p, 0), 0);
275 RTVEC_ELT (arg_vector, i) = p;
277 if (GET_CODE (p) == REG)
278 parmdecl_map[REGNO (p)] = parms;
279 else if (GET_CODE (p) == CONCAT)
281 rtx preal = gen_realpart (GET_MODE (XEXP (p, 0)), p);
282 rtx pimag = gen_imagpart (GET_MODE (preal), p);
284 if (GET_CODE (preal) == REG)
285 parmdecl_map[REGNO (preal)] = parms;
286 if (GET_CODE (pimag) == REG)
287 parmdecl_map[REGNO (pimag)] = parms;
290 /* This flag is cleared later
291 if the function ever modifies the value of the parm. */
292 TREE_READONLY (parms) = 1;
295 return arg_vector;
298 /* Copy NODE (which must be a DECL, but not a PARM_DECL). The DECL
299 originally was in the FROM_FN, but now it will be in the
300 TO_FN. */
302 tree
303 copy_decl_for_inlining (decl, from_fn, to_fn)
304 tree decl;
305 tree from_fn;
306 tree to_fn;
308 tree copy;
310 /* Copy the declaration. */
311 if (TREE_CODE (decl) == PARM_DECL || TREE_CODE (decl) == RESULT_DECL)
312 /* For a parameter, we must make an equivalent VAR_DECL, not a
313 new PARM_DECL. */
314 copy = build_decl (VAR_DECL, DECL_NAME (decl), TREE_TYPE (decl));
315 else
317 copy = copy_node (decl);
318 if (DECL_LANG_SPECIFIC (copy))
319 copy_lang_decl (copy);
322 /* Set the DECL_ABSTRACT_ORIGIN so the debugging routines know what
323 declaration inspired this copy. */
324 DECL_ABSTRACT_ORIGIN (copy) = DECL_ORIGIN (decl);
326 /* The new variable/label has no RTL, yet. */
327 DECL_RTL (copy) = NULL_RTX;
329 /* These args would always appear unused, if not for this. */
330 TREE_USED (copy) = 1;
332 /* Set the context for the new declaration. */
333 if (!DECL_CONTEXT (decl))
334 /* Globals stay global. */
336 else if (DECL_CONTEXT (decl) != from_fn)
337 /* Things that weren't in the scope of the function we're inlining
338 from aren't in the scope we're inlining too, either. */
340 else if (TREE_STATIC (decl))
341 /* Function-scoped static variables should say in the original
342 function. */
344 else
345 /* Ordinary automatic local variables are now in the scope of the
346 new function. */
347 DECL_CONTEXT (copy) = to_fn;
349 return copy;
352 /* Make the insns and PARM_DECLs of the current function permanent
353 and record other information in DECL_SAVED_INSNS to allow inlining
354 of this function in subsequent calls.
356 This routine need not copy any insns because we are not going
357 to immediately compile the insns in the insn chain. There
358 are two cases when we would compile the insns for FNDECL:
359 (1) when FNDECL is expanded inline, and (2) when FNDECL needs to
360 be output at the end of other compilation, because somebody took
361 its address. In the first case, the insns of FNDECL are copied
362 as it is expanded inline, so FNDECL's saved insns are not
363 modified. In the second case, FNDECL is used for the last time,
364 so modifying the rtl is not a problem.
366 We don't have to worry about FNDECL being inline expanded by
367 other functions which are written at the end of compilation
368 because flag_no_inline is turned on when we begin writing
369 functions at the end of compilation. */
371 void
372 save_for_inline_nocopy (fndecl)
373 tree fndecl;
375 rtx insn;
376 rtvec argvec;
377 rtx first_nonparm_insn;
379 /* Set up PARMDECL_MAP which maps pseudo-reg number to its PARM_DECL.
380 Later we set TREE_READONLY to 0 if the parm is modified inside the fn.
381 Also set up ARG_VECTOR, which holds the unmodified DECL_RTX values
382 for the parms, prior to elimination of virtual registers.
383 These values are needed for substituting parms properly. */
385 parmdecl_map = (tree *) xmalloc (max_parm_reg * sizeof (tree));
387 /* Make and emit a return-label if we have not already done so. */
389 if (return_label == 0)
391 return_label = gen_label_rtx ();
392 emit_label (return_label);
395 argvec = initialize_for_inline (fndecl);
397 /* If there are insns that copy parms from the stack into pseudo registers,
398 those insns are not copied. `expand_inline_function' must
399 emit the correct code to handle such things. */
401 insn = get_insns ();
402 if (GET_CODE (insn) != NOTE)
403 abort ();
405 /* Get the insn which signals the end of parameter setup code. */
406 first_nonparm_insn = get_first_nonparm_insn ();
408 /* Now just scan the chain of insns to see what happens to our
409 PARM_DECLs. If a PARM_DECL is used but never modified, we
410 can substitute its rtl directly when expanding inline (and
411 perform constant folding when its incoming value is constant).
412 Otherwise, we have to copy its value into a new register and track
413 the new register's life. */
414 in_nonparm_insns = 0;
415 for (insn = NEXT_INSN (insn); insn; insn = NEXT_INSN (insn))
417 if (insn == first_nonparm_insn)
418 in_nonparm_insns = 1;
420 if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
421 /* Record what interesting things happen to our parameters. */
422 note_stores (PATTERN (insn), note_modified_parmregs, NULL);
425 /* We have now allocated all that needs to be allocated permanently
426 on the rtx obstack. Set our high-water mark, so that we
427 can free the rest of this when the time comes. */
429 preserve_data ();
431 current_function->inl_max_label_num = max_label_num ();
432 current_function->inl_last_parm_insn = current_function->x_last_parm_insn;
433 current_function->original_arg_vector = argvec;
434 current_function->original_decl_initial = DECL_INITIAL (fndecl);
435 DECL_SAVED_INSNS (fndecl) = current_function;
437 /* Clean up. */
438 free (parmdecl_map);
441 /* Note whether a parameter is modified or not. */
443 static void
444 note_modified_parmregs (reg, x, data)
445 rtx reg;
446 rtx x ATTRIBUTE_UNUSED;
447 void *data ATTRIBUTE_UNUSED;
449 if (GET_CODE (reg) == REG && in_nonparm_insns
450 && REGNO (reg) < max_parm_reg
451 && REGNO (reg) >= FIRST_PSEUDO_REGISTER
452 && parmdecl_map[REGNO (reg)] != 0)
453 TREE_READONLY (parmdecl_map[REGNO (reg)]) = 0;
456 /* Unfortunately, we need a global copy of const_equiv map for communication
457 with a function called from note_stores. Be *very* careful that this
458 is used properly in the presence of recursion. */
460 varray_type global_const_equiv_varray;
462 #define FIXED_BASE_PLUS_P(X) \
463 (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == CONST_INT \
464 && GET_CODE (XEXP (X, 0)) == REG \
465 && REGNO (XEXP (X, 0)) >= FIRST_VIRTUAL_REGISTER \
466 && REGNO (XEXP (X, 0)) <= LAST_VIRTUAL_REGISTER)
468 /* Called to set up a mapping for the case where a parameter is in a
469 register. If it is read-only and our argument is a constant, set up the
470 constant equivalence.
472 If LOC is REG_USERVAR_P, the usual case, COPY must also have that flag set
473 if it is a register.
475 Also, don't allow hard registers here; they might not be valid when
476 substituted into insns. */
477 static void
478 process_reg_param (map, loc, copy)
479 struct inline_remap *map;
480 rtx loc, copy;
482 if ((GET_CODE (copy) != REG && GET_CODE (copy) != SUBREG)
483 || (GET_CODE (copy) == REG && REG_USERVAR_P (loc)
484 && ! REG_USERVAR_P (copy))
485 || (GET_CODE (copy) == REG
486 && REGNO (copy) < FIRST_PSEUDO_REGISTER))
488 rtx temp = copy_to_mode_reg (GET_MODE (loc), copy);
489 REG_USERVAR_P (temp) = REG_USERVAR_P (loc);
490 if (CONSTANT_P (copy) || FIXED_BASE_PLUS_P (copy))
491 SET_CONST_EQUIV_DATA (map, temp, copy, CONST_AGE_PARM);
492 copy = temp;
494 map->reg_map[REGNO (loc)] = copy;
497 /* Used by duplicate_eh_handlers to map labels for the exception table */
498 static struct inline_remap *eif_eh_map;
500 static rtx
501 expand_inline_function_eh_labelmap (label)
502 rtx label;
504 int index = CODE_LABEL_NUMBER (label);
505 return get_label_from_map (eif_eh_map, index);
508 /* Integrate the procedure defined by FNDECL. Note that this function
509 may wind up calling itself. Since the static variables are not
510 reentrant, we do not assign them until after the possibility
511 of recursion is eliminated.
513 If IGNORE is nonzero, do not produce a value.
514 Otherwise store the value in TARGET if it is nonzero and that is convenient.
516 Value is:
517 (rtx)-1 if we could not substitute the function
518 0 if we substituted it and it does not produce a value
519 else an rtx for where the value is stored. */
522 expand_inline_function (fndecl, parms, target, ignore, type,
523 structure_value_addr)
524 tree fndecl, parms;
525 rtx target;
526 int ignore;
527 tree type;
528 rtx structure_value_addr;
530 struct function *inlining_previous;
531 struct function *inl_f = DECL_SAVED_INSNS (fndecl);
532 tree formal, actual, block;
533 rtx parm_insns = inl_f->emit->x_first_insn;
534 rtx insns = (inl_f->inl_last_parm_insn
535 ? NEXT_INSN (inl_f->inl_last_parm_insn)
536 : parm_insns);
537 tree *arg_trees;
538 rtx *arg_vals;
539 rtx insn;
540 int max_regno;
541 register int i;
542 int min_labelno = inl_f->emit->x_first_label_num;
543 int max_labelno = inl_f->inl_max_label_num;
544 int nargs;
545 rtx local_return_label = 0;
546 rtx loc;
547 rtx stack_save = 0;
548 rtx temp;
549 struct inline_remap *map = 0;
550 #ifdef HAVE_cc0
551 rtx cc0_insn = 0;
552 #endif
553 rtvec arg_vector = (rtvec) inl_f->original_arg_vector;
554 rtx static_chain_value = 0;
555 int inl_max_uid;
557 /* The pointer used to track the true location of the memory used
558 for MAP->LABEL_MAP. */
559 rtx *real_label_map = 0;
561 /* Allow for equivalences of the pseudos we make for virtual fp and ap. */
562 max_regno = inl_f->emit->x_reg_rtx_no + 3;
563 if (max_regno < FIRST_PSEUDO_REGISTER)
564 abort ();
566 nargs = list_length (DECL_ARGUMENTS (fndecl));
568 /* Check that the parms type match and that sufficient arguments were
569 passed. Since the appropriate conversions or default promotions have
570 already been applied, the machine modes should match exactly. */
572 for (formal = DECL_ARGUMENTS (fndecl), actual = parms;
573 formal;
574 formal = TREE_CHAIN (formal), actual = TREE_CHAIN (actual))
576 tree arg;
577 enum machine_mode mode;
579 if (actual == 0)
580 return (rtx) (HOST_WIDE_INT) -1;
582 arg = TREE_VALUE (actual);
583 mode = TYPE_MODE (DECL_ARG_TYPE (formal));
585 if (mode != TYPE_MODE (TREE_TYPE (arg))
586 /* If they are block mode, the types should match exactly.
587 They don't match exactly if TREE_TYPE (FORMAL) == ERROR_MARK_NODE,
588 which could happen if the parameter has incomplete type. */
589 || (mode == BLKmode
590 && (TYPE_MAIN_VARIANT (TREE_TYPE (arg))
591 != TYPE_MAIN_VARIANT (TREE_TYPE (formal)))))
592 return (rtx) (HOST_WIDE_INT) -1;
595 /* Extra arguments are valid, but will be ignored below, so we must
596 evaluate them here for side-effects. */
597 for (; actual; actual = TREE_CHAIN (actual))
598 expand_expr (TREE_VALUE (actual), const0_rtx,
599 TYPE_MODE (TREE_TYPE (TREE_VALUE (actual))), 0);
601 /* Expand the function arguments. Do this first so that any
602 new registers get created before we allocate the maps. */
604 arg_vals = (rtx *) xmalloc (nargs * sizeof (rtx));
605 arg_trees = (tree *) xmalloc (nargs * sizeof (tree));
607 for (formal = DECL_ARGUMENTS (fndecl), actual = parms, i = 0;
608 formal;
609 formal = TREE_CHAIN (formal), actual = TREE_CHAIN (actual), i++)
611 /* Actual parameter, converted to the type of the argument within the
612 function. */
613 tree arg = convert (TREE_TYPE (formal), TREE_VALUE (actual));
614 /* Mode of the variable used within the function. */
615 enum machine_mode mode = TYPE_MODE (TREE_TYPE (formal));
616 int invisiref = 0;
618 arg_trees[i] = arg;
619 loc = RTVEC_ELT (arg_vector, i);
621 /* If this is an object passed by invisible reference, we copy the
622 object into a stack slot and save its address. If this will go
623 into memory, we do nothing now. Otherwise, we just expand the
624 argument. */
625 if (GET_CODE (loc) == MEM && GET_CODE (XEXP (loc, 0)) == REG
626 && REGNO (XEXP (loc, 0)) > LAST_VIRTUAL_REGISTER)
628 rtx stack_slot
629 = assign_stack_temp (TYPE_MODE (TREE_TYPE (arg)),
630 int_size_in_bytes (TREE_TYPE (arg)), 1);
631 MEM_SET_IN_STRUCT_P (stack_slot,
632 AGGREGATE_TYPE_P (TREE_TYPE (arg)));
634 store_expr (arg, stack_slot, 0);
636 arg_vals[i] = XEXP (stack_slot, 0);
637 invisiref = 1;
639 else if (GET_CODE (loc) != MEM)
641 if (GET_MODE (loc) != TYPE_MODE (TREE_TYPE (arg)))
642 /* The mode if LOC and ARG can differ if LOC was a variable
643 that had its mode promoted via PROMOTED_MODE. */
644 arg_vals[i] = convert_modes (GET_MODE (loc),
645 TYPE_MODE (TREE_TYPE (arg)),
646 expand_expr (arg, NULL_RTX, mode,
647 EXPAND_SUM),
648 TREE_UNSIGNED (TREE_TYPE (formal)));
649 else
650 arg_vals[i] = expand_expr (arg, NULL_RTX, mode, EXPAND_SUM);
652 else
653 arg_vals[i] = 0;
655 if (arg_vals[i] != 0
656 && (! TREE_READONLY (formal)
657 /* If the parameter is not read-only, copy our argument through
658 a register. Also, we cannot use ARG_VALS[I] if it overlaps
659 TARGET in any way. In the inline function, they will likely
660 be two different pseudos, and `safe_from_p' will make all
661 sorts of smart assumptions about their not conflicting.
662 But if ARG_VALS[I] overlaps TARGET, these assumptions are
663 wrong, so put ARG_VALS[I] into a fresh register.
664 Don't worry about invisible references, since their stack
665 temps will never overlap the target. */
666 || (target != 0
667 && ! invisiref
668 && (GET_CODE (arg_vals[i]) == REG
669 || GET_CODE (arg_vals[i]) == SUBREG
670 || GET_CODE (arg_vals[i]) == MEM)
671 && reg_overlap_mentioned_p (arg_vals[i], target))
672 /* ??? We must always copy a SUBREG into a REG, because it might
673 get substituted into an address, and not all ports correctly
674 handle SUBREGs in addresses. */
675 || (GET_CODE (arg_vals[i]) == SUBREG)))
676 arg_vals[i] = copy_to_mode_reg (GET_MODE (loc), arg_vals[i]);
678 if (arg_vals[i] != 0 && GET_CODE (arg_vals[i]) == REG
679 && POINTER_TYPE_P (TREE_TYPE (formal)))
680 mark_reg_pointer (arg_vals[i],
681 (TYPE_ALIGN (TREE_TYPE (TREE_TYPE (formal)))
682 / BITS_PER_UNIT));
685 /* Allocate the structures we use to remap things. */
687 map = (struct inline_remap *) xmalloc (sizeof (struct inline_remap));
688 map->fndecl = fndecl;
690 map->reg_map = (rtx *) xcalloc (max_regno, sizeof (rtx));
692 /* We used to use alloca here, but the size of what it would try to
693 allocate would occasionally cause it to exceed the stack limit and
694 cause unpredictable core dumps. */
695 real_label_map
696 = (rtx *) xmalloc ((max_labelno) * sizeof (rtx));
697 map->label_map = real_label_map;
699 inl_max_uid = (inl_f->emit->x_cur_insn_uid + 1);
700 map->insn_map = (rtx *) xcalloc (inl_max_uid, sizeof (rtx));
701 map->min_insnno = 0;
702 map->max_insnno = inl_max_uid;
704 map->integrating = 1;
706 /* const_equiv_varray maps pseudos in our routine to constants, so
707 it needs to be large enough for all our pseudos. This is the
708 number we are currently using plus the number in the called
709 routine, plus 15 for each arg, five to compute the virtual frame
710 pointer, and five for the return value. This should be enough
711 for most cases. We do not reference entries outside the range of
712 the map.
714 ??? These numbers are quite arbitrary and were obtained by
715 experimentation. At some point, we should try to allocate the
716 table after all the parameters are set up so we an more accurately
717 estimate the number of pseudos we will need. */
719 VARRAY_CONST_EQUIV_INIT (map->const_equiv_varray,
720 (max_reg_num ()
721 + (max_regno - FIRST_PSEUDO_REGISTER)
722 + 15 * nargs
723 + 10),
724 "expand_inline_function");
725 map->const_age = 0;
727 /* Record the current insn in case we have to set up pointers to frame
728 and argument memory blocks. If there are no insns yet, add a dummy
729 insn that can be used as an insertion point. */
730 map->insns_at_start = get_last_insn ();
731 if (map->insns_at_start == 0)
732 map->insns_at_start = emit_note (NULL_PTR, NOTE_INSN_DELETED);
734 map->regno_pointer_flag = inl_f->emit->regno_pointer_flag;
735 map->regno_pointer_align = inl_f->emit->regno_pointer_align;
737 /* Update the outgoing argument size to allow for those in the inlined
738 function. */
739 if (inl_f->outgoing_args_size > current_function_outgoing_args_size)
740 current_function_outgoing_args_size = inl_f->outgoing_args_size;
742 /* If the inline function needs to make PIC references, that means
743 that this function's PIC offset table must be used. */
744 if (inl_f->uses_pic_offset_table)
745 current_function_uses_pic_offset_table = 1;
747 /* If this function needs a context, set it up. */
748 if (inl_f->needs_context)
749 static_chain_value = lookup_static_chain (fndecl);
751 if (GET_CODE (parm_insns) == NOTE
752 && NOTE_LINE_NUMBER (parm_insns) > 0)
754 rtx note = emit_note (NOTE_SOURCE_FILE (parm_insns),
755 NOTE_LINE_NUMBER (parm_insns));
756 if (note)
757 RTX_INTEGRATED_P (note) = 1;
760 /* Figure out where the blocks are if we're going to have to insert
761 new BLOCKs into the existing block tree. */
762 if (current_function->x_whole_function_mode_p)
763 find_loop_tree_blocks ();
765 /* Process each argument. For each, set up things so that the function's
766 reference to the argument will refer to the argument being passed.
767 We only replace REG with REG here. Any simplifications are done
768 via const_equiv_map.
770 We make two passes: In the first, we deal with parameters that will
771 be placed into registers, since we need to ensure that the allocated
772 register number fits in const_equiv_map. Then we store all non-register
773 parameters into their memory location. */
775 /* Don't try to free temp stack slots here, because we may put one of the
776 parameters into a temp stack slot. */
778 for (i = 0; i < nargs; i++)
780 rtx copy = arg_vals[i];
782 loc = RTVEC_ELT (arg_vector, i);
784 /* There are three cases, each handled separately. */
785 if (GET_CODE (loc) == MEM && GET_CODE (XEXP (loc, 0)) == REG
786 && REGNO (XEXP (loc, 0)) > LAST_VIRTUAL_REGISTER)
788 /* This must be an object passed by invisible reference (it could
789 also be a variable-sized object, but we forbid inlining functions
790 with variable-sized arguments). COPY is the address of the
791 actual value (this computation will cause it to be copied). We
792 map that address for the register, noting the actual address as
793 an equivalent in case it can be substituted into the insns. */
795 if (GET_CODE (copy) != REG)
797 temp = copy_addr_to_reg (copy);
798 if (CONSTANT_P (copy) || FIXED_BASE_PLUS_P (copy))
799 SET_CONST_EQUIV_DATA (map, temp, copy, CONST_AGE_PARM);
800 copy = temp;
802 map->reg_map[REGNO (XEXP (loc, 0))] = copy;
804 else if (GET_CODE (loc) == MEM)
806 /* This is the case of a parameter that lives in memory. It
807 will live in the block we allocate in the called routine's
808 frame that simulates the incoming argument area. Do nothing
809 with the parameter now; we will call store_expr later. In
810 this case, however, we must ensure that the virtual stack and
811 incoming arg rtx values are expanded now so that we can be
812 sure we have enough slots in the const equiv map since the
813 store_expr call can easily blow the size estimate. */
814 if (DECL_FRAME_SIZE (fndecl) != 0)
815 copy_rtx_and_substitute (virtual_stack_vars_rtx, map, 0);
817 if (DECL_SAVED_INSNS (fndecl)->args_size != 0)
818 copy_rtx_and_substitute (virtual_incoming_args_rtx, map, 0);
820 else if (GET_CODE (loc) == REG)
821 process_reg_param (map, loc, copy);
822 else if (GET_CODE (loc) == CONCAT)
824 rtx locreal = gen_realpart (GET_MODE (XEXP (loc, 0)), loc);
825 rtx locimag = gen_imagpart (GET_MODE (XEXP (loc, 0)), loc);
826 rtx copyreal = gen_realpart (GET_MODE (locreal), copy);
827 rtx copyimag = gen_imagpart (GET_MODE (locimag), copy);
829 process_reg_param (map, locreal, copyreal);
830 process_reg_param (map, locimag, copyimag);
832 else
833 abort ();
836 /* Tell copy_rtx_and_substitute to handle constant pool SYMBOL_REFs
837 specially. This function can be called recursively, so we need to
838 save the previous value. */
839 inlining_previous = inlining;
840 inlining = inl_f;
842 /* Now do the parameters that will be placed in memory. */
844 for (formal = DECL_ARGUMENTS (fndecl), i = 0;
845 formal; formal = TREE_CHAIN (formal), i++)
847 loc = RTVEC_ELT (arg_vector, i);
849 if (GET_CODE (loc) == MEM
850 /* Exclude case handled above. */
851 && ! (GET_CODE (XEXP (loc, 0)) == REG
852 && REGNO (XEXP (loc, 0)) > LAST_VIRTUAL_REGISTER))
854 rtx note = emit_note (DECL_SOURCE_FILE (formal),
855 DECL_SOURCE_LINE (formal));
856 if (note)
857 RTX_INTEGRATED_P (note) = 1;
859 /* Compute the address in the area we reserved and store the
860 value there. */
861 temp = copy_rtx_and_substitute (loc, map, 1);
862 subst_constants (&temp, NULL_RTX, map, 1);
863 apply_change_group ();
864 if (! memory_address_p (GET_MODE (temp), XEXP (temp, 0)))
865 temp = change_address (temp, VOIDmode, XEXP (temp, 0));
866 store_expr (arg_trees[i], temp, 0);
870 /* Deal with the places that the function puts its result.
871 We are driven by what is placed into DECL_RESULT.
873 Initially, we assume that we don't have anything special handling for
874 REG_FUNCTION_RETURN_VALUE_P. */
876 map->inline_target = 0;
877 loc = DECL_RTL (DECL_RESULT (fndecl));
879 if (TYPE_MODE (type) == VOIDmode)
880 /* There is no return value to worry about. */
882 else if (GET_CODE (loc) == MEM)
884 if (GET_CODE (XEXP (loc, 0)) == ADDRESSOF)
886 temp = copy_rtx_and_substitute (loc, map, 1);
887 subst_constants (&temp, NULL_RTX, map, 1);
888 apply_change_group ();
889 target = temp;
891 else
893 if (! structure_value_addr
894 || ! aggregate_value_p (DECL_RESULT (fndecl)))
895 abort ();
897 /* Pass the function the address in which to return a structure
898 value. Note that a constructor can cause someone to call us
899 with STRUCTURE_VALUE_ADDR, but the initialization takes place
900 via the first parameter, rather than the struct return address.
902 We have two cases: If the address is a simple register
903 indirect, use the mapping mechanism to point that register to
904 our structure return address. Otherwise, store the structure
905 return value into the place that it will be referenced from. */
907 if (GET_CODE (XEXP (loc, 0)) == REG)
909 temp = force_operand (structure_value_addr, NULL_RTX);
910 temp = force_reg (Pmode, temp);
911 map->reg_map[REGNO (XEXP (loc, 0))] = temp;
913 if (CONSTANT_P (structure_value_addr)
914 || GET_CODE (structure_value_addr) == ADDRESSOF
915 || (GET_CODE (structure_value_addr) == PLUS
916 && (XEXP (structure_value_addr, 0)
917 == virtual_stack_vars_rtx)
918 && (GET_CODE (XEXP (structure_value_addr, 1))
919 == CONST_INT)))
921 SET_CONST_EQUIV_DATA (map, temp, structure_value_addr,
922 CONST_AGE_PARM);
925 else
927 temp = copy_rtx_and_substitute (loc, map, 1);
928 subst_constants (&temp, NULL_RTX, map, 0);
929 apply_change_group ();
930 emit_move_insn (temp, structure_value_addr);
934 else if (ignore)
935 /* We will ignore the result value, so don't look at its structure.
936 Note that preparations for an aggregate return value
937 do need to be made (above) even if it will be ignored. */
939 else if (GET_CODE (loc) == REG)
941 /* The function returns an object in a register and we use the return
942 value. Set up our target for remapping. */
944 /* Machine mode function was declared to return. */
945 enum machine_mode departing_mode = TYPE_MODE (type);
946 /* (Possibly wider) machine mode it actually computes
947 (for the sake of callers that fail to declare it right).
948 We have to use the mode of the result's RTL, rather than
949 its type, since expand_function_start may have promoted it. */
950 enum machine_mode arriving_mode
951 = GET_MODE (DECL_RTL (DECL_RESULT (fndecl)));
952 rtx reg_to_map;
954 /* Don't use MEMs as direct targets because on some machines
955 substituting a MEM for a REG makes invalid insns.
956 Let the combiner substitute the MEM if that is valid. */
957 if (target == 0 || GET_CODE (target) != REG
958 || GET_MODE (target) != departing_mode)
960 /* Don't make BLKmode registers. If this looks like
961 a BLKmode object being returned in a register, get
962 the mode from that, otherwise abort. */
963 if (departing_mode == BLKmode)
965 if (REG == GET_CODE (DECL_RTL (DECL_RESULT (fndecl))))
967 departing_mode = GET_MODE (DECL_RTL (DECL_RESULT (fndecl)));
968 arriving_mode = departing_mode;
970 else
971 abort();
974 target = gen_reg_rtx (departing_mode);
977 /* If function's value was promoted before return,
978 avoid machine mode mismatch when we substitute INLINE_TARGET.
979 But TARGET is what we will return to the caller. */
980 if (arriving_mode != departing_mode)
982 /* Avoid creating a paradoxical subreg wider than
983 BITS_PER_WORD, since that is illegal. */
984 if (GET_MODE_BITSIZE (arriving_mode) > BITS_PER_WORD)
986 if (!TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (departing_mode),
987 GET_MODE_BITSIZE (arriving_mode)))
988 /* Maybe could be handled by using convert_move () ? */
989 abort ();
990 reg_to_map = gen_reg_rtx (arriving_mode);
991 target = gen_lowpart (departing_mode, reg_to_map);
993 else
994 reg_to_map = gen_rtx_SUBREG (arriving_mode, target, 0);
996 else
997 reg_to_map = target;
999 /* Usually, the result value is the machine's return register.
1000 Sometimes it may be a pseudo. Handle both cases. */
1001 if (REG_FUNCTION_VALUE_P (loc))
1002 map->inline_target = reg_to_map;
1003 else
1004 map->reg_map[REGNO (loc)] = reg_to_map;
1006 else
1007 abort ();
1009 /* Make a fresh binding contour that we can easily remove. Do this after
1010 expanding our arguments so cleanups are properly scoped. */
1011 expand_start_bindings (0);
1013 /* Initialize label_map. get_label_from_map will actually make
1014 the labels. */
1015 bzero ((char *) &map->label_map [min_labelno],
1016 (max_labelno - min_labelno) * sizeof (rtx));
1018 /* Perform postincrements before actually calling the function. */
1019 emit_queue ();
1021 /* Clean up stack so that variables might have smaller offsets. */
1022 do_pending_stack_adjust ();
1024 /* Save a copy of the location of const_equiv_varray for
1025 mark_stores, called via note_stores. */
1026 global_const_equiv_varray = map->const_equiv_varray;
1028 /* If the called function does an alloca, save and restore the
1029 stack pointer around the call. This saves stack space, but
1030 also is required if this inline is being done between two
1031 pushes. */
1032 if (inl_f->calls_alloca)
1033 emit_stack_save (SAVE_BLOCK, &stack_save, NULL_RTX);
1035 /* Now copy the insns one by one. Do this in two passes, first the insns and
1036 then their REG_NOTES, just like save_for_inline. */
1038 /* This loop is very similar to the loop in copy_loop_body in unroll.c. */
1040 for (insn = insns; insn; insn = NEXT_INSN (insn))
1042 rtx copy, pattern, set;
1044 map->orig_asm_operands_vector = 0;
1046 switch (GET_CODE (insn))
1048 case INSN:
1049 pattern = PATTERN (insn);
1050 set = single_set (insn);
1051 copy = 0;
1052 if (GET_CODE (pattern) == USE
1053 && GET_CODE (XEXP (pattern, 0)) == REG
1054 && REG_FUNCTION_VALUE_P (XEXP (pattern, 0)))
1055 /* The (USE (REG n)) at return from the function should
1056 be ignored since we are changing (REG n) into
1057 inline_target. */
1058 break;
1060 /* If the inline fn needs eh context, make sure that
1061 the current fn has one. */
1062 if (GET_CODE (pattern) == USE
1063 && find_reg_note (insn, REG_EH_CONTEXT, 0) != 0)
1064 get_eh_context ();
1066 /* Ignore setting a function value that we don't want to use. */
1067 if (map->inline_target == 0
1068 && set != 0
1069 && GET_CODE (SET_DEST (set)) == REG
1070 && REG_FUNCTION_VALUE_P (SET_DEST (set)))
1072 if (volatile_refs_p (SET_SRC (set)))
1074 rtx new_set;
1076 /* If we must not delete the source,
1077 load it into a new temporary. */
1078 copy = emit_insn (copy_rtx_and_substitute (pattern, map, 0));
1080 new_set = single_set (copy);
1081 if (new_set == 0)
1082 abort ();
1084 SET_DEST (new_set)
1085 = gen_reg_rtx (GET_MODE (SET_DEST (new_set)));
1087 /* If the source and destination are the same and it
1088 has a note on it, keep the insn. */
1089 else if (rtx_equal_p (SET_DEST (set), SET_SRC (set))
1090 && REG_NOTES (insn) != 0)
1091 copy = emit_insn (copy_rtx_and_substitute (pattern, map, 0));
1092 else
1093 break;
1096 /* If this is setting the static chain rtx, omit it. */
1097 else if (static_chain_value != 0
1098 && set != 0
1099 && GET_CODE (SET_DEST (set)) == REG
1100 && rtx_equal_p (SET_DEST (set),
1101 static_chain_incoming_rtx))
1102 break;
1104 /* If this is setting the static chain pseudo, set it from
1105 the value we want to give it instead. */
1106 else if (static_chain_value != 0
1107 && set != 0
1108 && rtx_equal_p (SET_SRC (set),
1109 static_chain_incoming_rtx))
1111 rtx newdest = copy_rtx_and_substitute (SET_DEST (set), map, 1);
1113 copy = emit_move_insn (newdest, static_chain_value);
1114 static_chain_value = 0;
1117 /* If this is setting the virtual stack vars register, this must
1118 be the code at the handler for a builtin longjmp. The value
1119 saved in the setjmp buffer will be the address of the frame
1120 we've made for this inlined instance within our frame. But we
1121 know the offset of that value so we can use it to reconstruct
1122 our virtual stack vars register from that value. If we are
1123 copying it from the stack pointer, leave it unchanged. */
1124 else if (set != 0
1125 && rtx_equal_p (SET_DEST (set), virtual_stack_vars_rtx))
1127 HOST_WIDE_INT offset;
1128 temp = map->reg_map[REGNO (SET_DEST (set))];
1129 temp = VARRAY_CONST_EQUIV (map->const_equiv_varray,
1130 REGNO (temp)).rtx;
1132 if (rtx_equal_p (temp, virtual_stack_vars_rtx))
1133 offset = 0;
1134 else if (GET_CODE (temp) == PLUS
1135 && rtx_equal_p (XEXP (temp, 0), virtual_stack_vars_rtx)
1136 && GET_CODE (XEXP (temp, 1)) == CONST_INT)
1137 offset = INTVAL (XEXP (temp, 1));
1138 else
1139 abort ();
1141 if (rtx_equal_p (SET_SRC (set), stack_pointer_rtx))
1142 temp = SET_SRC (set);
1143 else
1144 temp = force_operand (plus_constant (SET_SRC (set),
1145 - offset),
1146 NULL_RTX);
1148 copy = emit_move_insn (virtual_stack_vars_rtx, temp);
1151 else
1152 copy = emit_insn (copy_rtx_and_substitute (pattern, map, 0));
1153 /* REG_NOTES will be copied later. */
1155 #ifdef HAVE_cc0
1156 /* If this insn is setting CC0, it may need to look at
1157 the insn that uses CC0 to see what type of insn it is.
1158 In that case, the call to recog via validate_change will
1159 fail. So don't substitute constants here. Instead,
1160 do it when we emit the following insn.
1162 For example, see the pyr.md file. That machine has signed and
1163 unsigned compares. The compare patterns must check the
1164 following branch insn to see which what kind of compare to
1165 emit.
1167 If the previous insn set CC0, substitute constants on it as
1168 well. */
1169 if (sets_cc0_p (PATTERN (copy)) != 0)
1170 cc0_insn = copy;
1171 else
1173 if (cc0_insn)
1174 try_constants (cc0_insn, map);
1175 cc0_insn = 0;
1176 try_constants (copy, map);
1178 #else
1179 try_constants (copy, map);
1180 #endif
1181 break;
1183 case JUMP_INSN:
1184 if (GET_CODE (PATTERN (insn)) == RETURN
1185 || (GET_CODE (PATTERN (insn)) == PARALLEL
1186 && GET_CODE (XVECEXP (PATTERN (insn), 0, 0)) == RETURN))
1188 if (local_return_label == 0)
1189 local_return_label = gen_label_rtx ();
1190 pattern = gen_jump (local_return_label);
1192 else
1193 pattern = copy_rtx_and_substitute (PATTERN (insn), map, 0);
1195 copy = emit_jump_insn (pattern);
1197 #ifdef HAVE_cc0
1198 if (cc0_insn)
1199 try_constants (cc0_insn, map);
1200 cc0_insn = 0;
1201 #endif
1202 try_constants (copy, map);
1204 /* If this used to be a conditional jump insn but whose branch
1205 direction is now know, we must do something special. */
1206 if (condjump_p (insn) && ! simplejump_p (insn) && map->last_pc_value)
1208 #ifdef HAVE_cc0
1209 /* If the previous insn set cc0 for us, delete it. */
1210 if (sets_cc0_p (PREV_INSN (copy)))
1211 delete_insn (PREV_INSN (copy));
1212 #endif
1214 /* If this is now a no-op, delete it. */
1215 if (map->last_pc_value == pc_rtx)
1217 delete_insn (copy);
1218 copy = 0;
1220 else
1221 /* Otherwise, this is unconditional jump so we must put a
1222 BARRIER after it. We could do some dead code elimination
1223 here, but jump.c will do it just as well. */
1224 emit_barrier ();
1226 break;
1228 case CALL_INSN:
1229 pattern = copy_rtx_and_substitute (PATTERN (insn), map, 0);
1230 copy = emit_call_insn (pattern);
1232 /* Because the USAGE information potentially contains objects other
1233 than hard registers, we need to copy it. */
1234 CALL_INSN_FUNCTION_USAGE (copy)
1235 = copy_rtx_and_substitute (CALL_INSN_FUNCTION_USAGE (insn),
1236 map, 0);
1238 #ifdef HAVE_cc0
1239 if (cc0_insn)
1240 try_constants (cc0_insn, map);
1241 cc0_insn = 0;
1242 #endif
1243 try_constants (copy, map);
1245 /* Be lazy and assume CALL_INSNs clobber all hard registers. */
1246 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1247 VARRAY_CONST_EQUIV (map->const_equiv_varray, i).rtx = 0;
1248 break;
1250 case CODE_LABEL:
1251 copy = emit_label (get_label_from_map (map,
1252 CODE_LABEL_NUMBER (insn)));
1253 LABEL_NAME (copy) = LABEL_NAME (insn);
1254 map->const_age++;
1255 break;
1257 case BARRIER:
1258 copy = emit_barrier ();
1259 break;
1261 case NOTE:
1262 /* It is important to discard function-end and function-beg notes,
1263 so we have only one of each in the current function.
1264 Also, NOTE_INSN_DELETED notes aren't useful (save_for_inline
1265 deleted these in the copy used for continuing compilation,
1266 not the copy used for inlining). */
1267 if (NOTE_LINE_NUMBER (insn) != NOTE_INSN_FUNCTION_END
1268 && NOTE_LINE_NUMBER (insn) != NOTE_INSN_FUNCTION_BEG
1269 && NOTE_LINE_NUMBER (insn) != NOTE_INSN_DELETED)
1271 copy = emit_note (NOTE_SOURCE_FILE (insn),
1272 NOTE_LINE_NUMBER (insn));
1273 if (copy
1274 && (NOTE_LINE_NUMBER (copy) == NOTE_INSN_EH_REGION_BEG
1275 || NOTE_LINE_NUMBER (copy) == NOTE_INSN_EH_REGION_END))
1277 rtx label
1278 = get_label_from_map (map, NOTE_EH_HANDLER (copy));
1280 /* we have to duplicate the handlers for the original */
1281 if (NOTE_LINE_NUMBER (copy) == NOTE_INSN_EH_REGION_BEG)
1283 /* We need to duplicate the handlers for the EH region
1284 and we need to indicate where the label map is */
1285 eif_eh_map = map;
1286 duplicate_eh_handlers (NOTE_EH_HANDLER (copy),
1287 CODE_LABEL_NUMBER (label),
1288 expand_inline_function_eh_labelmap);
1291 /* We have to forward these both to match the new exception
1292 region. */
1293 NOTE_EH_HANDLER (copy) = CODE_LABEL_NUMBER (label);
1296 else
1297 copy = 0;
1298 break;
1300 default:
1301 abort ();
1304 if (copy)
1305 RTX_INTEGRATED_P (copy) = 1;
1307 map->insn_map[INSN_UID (insn)] = copy;
1310 /* Now copy the REG_NOTES. Increment const_age, so that only constants
1311 from parameters can be substituted in. These are the only ones that
1312 are valid across the entire function. */
1313 map->const_age++;
1314 for (insn = insns; insn; insn = NEXT_INSN (insn))
1315 if (GET_RTX_CLASS (GET_CODE (insn)) == 'i'
1316 && map->insn_map[INSN_UID (insn)]
1317 && REG_NOTES (insn))
1319 rtx tem = copy_rtx_and_substitute (REG_NOTES (insn), map, 0);
1321 /* We must also do subst_constants, in case one of our parameters
1322 has const type and constant value. */
1323 subst_constants (&tem, NULL_RTX, map, 0);
1324 apply_change_group ();
1325 REG_NOTES (map->insn_map[INSN_UID (insn)]) = tem;
1328 if (local_return_label)
1329 emit_label (local_return_label);
1331 /* Restore the stack pointer if we saved it above. */
1332 if (inl_f->calls_alloca)
1333 emit_stack_restore (SAVE_BLOCK, stack_save, NULL_RTX);
1335 /* Make copies of the decls of the symbols in the inline function, so that
1336 the copies of the variables get declared in the current function. Set
1337 up things so that lookup_static_chain knows that to interpret registers
1338 in SAVE_EXPRs for TYPE_SIZEs as local. */
1340 inline_function_decl = fndecl;
1341 integrate_parm_decls (DECL_ARGUMENTS (fndecl), map, arg_vector);
1342 block = integrate_decl_tree (inl_f->original_decl_initial, map);
1343 BLOCK_ABSTRACT_ORIGIN (block) = (DECL_ABSTRACT_ORIGIN (fndecl) == NULL
1344 ? fndecl : DECL_ABSTRACT_ORIGIN (fndecl));
1345 inline_function_decl = 0;
1347 if (current_function->x_whole_function_mode_p)
1348 /* Insert the block into the already existing block-tree. */
1349 retrofit_block (block, map->insns_at_start);
1350 else
1351 /* In statement-at-a-time mode, we just tell the front-end to add
1352 this block to the list of blocks at this binding level. We
1353 can't do it the way it's done for function-at-a-time mode the
1354 superblocks have not been created yet. */
1355 insert_block (block);
1357 /* End the scope containing the copied formal parameter variables
1358 and copied LABEL_DECLs. We pass NULL_TREE for the variables list
1359 here so that expand_end_bindings will not check for unused
1360 variables. That's already been checked for when the inlined
1361 function was defined. */
1362 expand_end_bindings (NULL_TREE, 1, 1);
1364 /* Must mark the line number note after inlined functions as a repeat, so
1365 that the test coverage code can avoid counting the call twice. This
1366 just tells the code to ignore the immediately following line note, since
1367 there already exists a copy of this note before the expanded inline call.
1368 This line number note is still needed for debugging though, so we can't
1369 delete it. */
1370 if (flag_test_coverage)
1371 emit_note (0, NOTE_REPEATED_LINE_NUMBER);
1373 emit_line_note (input_filename, lineno);
1375 /* If the function returns a BLKmode object in a register, copy it
1376 out of the temp register into a BLKmode memory object. */
1377 if (target
1378 && TYPE_MODE (TREE_TYPE (TREE_TYPE (fndecl))) == BLKmode
1379 && ! aggregate_value_p (TREE_TYPE (TREE_TYPE (fndecl))))
1380 target = copy_blkmode_from_reg (0, target, TREE_TYPE (TREE_TYPE (fndecl)));
1382 if (structure_value_addr)
1384 target = gen_rtx_MEM (TYPE_MODE (type),
1385 memory_address (TYPE_MODE (type),
1386 structure_value_addr));
1387 MEM_SET_IN_STRUCT_P (target, 1);
1390 /* Make sure we free the things we explicitly allocated with xmalloc. */
1391 if (real_label_map)
1392 free (real_label_map);
1393 VARRAY_FREE (map->const_equiv_varray);
1394 free (map->reg_map);
1395 free (map->insn_map);
1396 free (map);
1397 free (arg_vals);
1398 free (arg_trees);
1400 inlining = inlining_previous;
1402 return target;
1405 /* Given a chain of PARM_DECLs, ARGS, copy each decl into a VAR_DECL,
1406 push all of those decls and give each one the corresponding home. */
1408 static void
1409 integrate_parm_decls (args, map, arg_vector)
1410 tree args;
1411 struct inline_remap *map;
1412 rtvec arg_vector;
1414 register tree tail;
1415 register int i;
1417 for (tail = args, i = 0; tail; tail = TREE_CHAIN (tail), i++)
1419 tree decl = copy_decl_for_inlining (tail, map->fndecl,
1420 current_function_decl);
1421 rtx new_decl_rtl
1422 = copy_rtx_and_substitute (RTVEC_ELT (arg_vector, i), map, 1);
1424 /* We really should be setting DECL_INCOMING_RTL to something reasonable
1425 here, but that's going to require some more work. */
1426 /* DECL_INCOMING_RTL (decl) = ?; */
1427 /* Fully instantiate the address with the equivalent form so that the
1428 debugging information contains the actual register, instead of the
1429 virtual register. Do this by not passing an insn to
1430 subst_constants. */
1431 subst_constants (&new_decl_rtl, NULL_RTX, map, 1);
1432 apply_change_group ();
1433 DECL_RTL (decl) = new_decl_rtl;
1437 /* Given a BLOCK node LET, push decls and levels so as to construct in the
1438 current function a tree of contexts isomorphic to the one that is given.
1440 MAP, if nonzero, is a pointer to an inline_remap map which indicates how
1441 registers used in the DECL_RTL field should be remapped. If it is zero,
1442 no mapping is necessary. */
1444 static tree
1445 integrate_decl_tree (let, map)
1446 tree let;
1447 struct inline_remap *map;
1449 tree t;
1450 tree new_block;
1451 tree *next;
1453 new_block = make_node (BLOCK);
1454 next = &BLOCK_VARS (new_block);
1456 for (t = BLOCK_VARS (let); t; t = TREE_CHAIN (t))
1458 tree d;
1460 push_obstacks_nochange ();
1461 saveable_allocation ();
1462 d = copy_decl_for_inlining (t, map->fndecl, current_function_decl);
1463 pop_obstacks ();
1465 if (DECL_RTL (t) != 0)
1467 DECL_RTL (d) = copy_rtx_and_substitute (DECL_RTL (t), map, 1);
1469 /* Fully instantiate the address with the equivalent form so that the
1470 debugging information contains the actual register, instead of the
1471 virtual register. Do this by not passing an insn to
1472 subst_constants. */
1473 subst_constants (&DECL_RTL (d), NULL_RTX, map, 1);
1474 apply_change_group ();
1477 /* Add this declaration to the list of variables in the new
1478 block. */
1479 *next = d;
1480 next = &TREE_CHAIN (d);
1483 next = &BLOCK_SUBBLOCKS (new_block);
1484 for (t = BLOCK_SUBBLOCKS (let); t; t = BLOCK_CHAIN (t))
1486 *next = integrate_decl_tree (t, map);
1487 BLOCK_SUPERCONTEXT (*next) = new_block;
1488 next = &BLOCK_CHAIN (*next);
1491 TREE_USED (new_block) = TREE_USED (let);
1492 BLOCK_ABSTRACT_ORIGIN (new_block) = let;
1494 return new_block;
1497 /* Create a new copy of an rtx. Recursively copies the operands of the rtx,
1498 except for those few rtx codes that are sharable.
1500 We always return an rtx that is similar to that incoming rtx, with the
1501 exception of possibly changing a REG to a SUBREG or vice versa. No
1502 rtl is ever emitted.
1504 If FOR_LHS is nonzero, if means we are processing something that will
1505 be the LHS of a SET. In that case, we copy RTX_UNCHANGING_P even if
1506 inlining since we need to be conservative in how it is set for
1507 such cases.
1509 Handle constants that need to be placed in the constant pool by
1510 calling `force_const_mem'. */
1513 copy_rtx_and_substitute (orig, map, for_lhs)
1514 register rtx orig;
1515 struct inline_remap *map;
1516 int for_lhs;
1518 register rtx copy, temp;
1519 register int i, j;
1520 register RTX_CODE code;
1521 register enum machine_mode mode;
1522 register const char *format_ptr;
1523 int regno;
1525 if (orig == 0)
1526 return 0;
1528 code = GET_CODE (orig);
1529 mode = GET_MODE (orig);
1531 switch (code)
1533 case REG:
1534 /* If the stack pointer register shows up, it must be part of
1535 stack-adjustments (*not* because we eliminated the frame pointer!).
1536 Small hard registers are returned as-is. Pseudo-registers
1537 go through their `reg_map'. */
1538 regno = REGNO (orig);
1539 if (regno <= LAST_VIRTUAL_REGISTER
1540 || (map->integrating
1541 && DECL_SAVED_INSNS (map->fndecl)->internal_arg_pointer == orig))
1543 /* Some hard registers are also mapped,
1544 but others are not translated. */
1545 if (map->reg_map[regno] != 0)
1546 return map->reg_map[regno];
1548 /* If this is the virtual frame pointer, make space in current
1549 function's stack frame for the stack frame of the inline function.
1551 Copy the address of this area into a pseudo. Map
1552 virtual_stack_vars_rtx to this pseudo and set up a constant
1553 equivalence for it to be the address. This will substitute the
1554 address into insns where it can be substituted and use the new
1555 pseudo where it can't. */
1556 if (regno == VIRTUAL_STACK_VARS_REGNUM)
1558 rtx loc, seq;
1559 int size = get_func_frame_size (DECL_SAVED_INSNS (map->fndecl));
1561 #ifdef FRAME_GROWS_DOWNWARD
1562 /* In this case, virtual_stack_vars_rtx points to one byte
1563 higher than the top of the frame area. So make sure we
1564 allocate a big enough chunk to keep the frame pointer
1565 aligned like a real one. */
1566 size = CEIL_ROUND (size, BIGGEST_ALIGNMENT / BITS_PER_UNIT);
1567 #endif
1568 start_sequence ();
1569 loc = assign_stack_temp (BLKmode, size, 1);
1570 loc = XEXP (loc, 0);
1571 #ifdef FRAME_GROWS_DOWNWARD
1572 /* In this case, virtual_stack_vars_rtx points to one byte
1573 higher than the top of the frame area. So compute the offset
1574 to one byte higher than our substitute frame. */
1575 loc = plus_constant (loc, size);
1576 #endif
1577 map->reg_map[regno] = temp
1578 = force_reg (Pmode, force_operand (loc, NULL_RTX));
1580 #ifdef STACK_BOUNDARY
1581 mark_reg_pointer (map->reg_map[regno],
1582 STACK_BOUNDARY / BITS_PER_UNIT);
1583 #endif
1585 SET_CONST_EQUIV_DATA (map, temp, loc, CONST_AGE_PARM);
1587 seq = gen_sequence ();
1588 end_sequence ();
1589 emit_insn_after (seq, map->insns_at_start);
1590 return temp;
1592 else if (regno == VIRTUAL_INCOMING_ARGS_REGNUM
1593 || (map->integrating
1594 && (DECL_SAVED_INSNS (map->fndecl)->internal_arg_pointer
1595 == orig)))
1597 /* Do the same for a block to contain any arguments referenced
1598 in memory. */
1599 rtx loc, seq;
1600 int size = DECL_SAVED_INSNS (map->fndecl)->args_size;
1602 start_sequence ();
1603 loc = assign_stack_temp (BLKmode, size, 1);
1604 loc = XEXP (loc, 0);
1605 /* When arguments grow downward, the virtual incoming
1606 args pointer points to the top of the argument block,
1607 so the remapped location better do the same. */
1608 #ifdef ARGS_GROW_DOWNWARD
1609 loc = plus_constant (loc, size);
1610 #endif
1611 map->reg_map[regno] = temp
1612 = force_reg (Pmode, force_operand (loc, NULL_RTX));
1614 #ifdef STACK_BOUNDARY
1615 mark_reg_pointer (map->reg_map[regno],
1616 STACK_BOUNDARY / BITS_PER_UNIT);
1617 #endif
1619 SET_CONST_EQUIV_DATA (map, temp, loc, CONST_AGE_PARM);
1621 seq = gen_sequence ();
1622 end_sequence ();
1623 emit_insn_after (seq, map->insns_at_start);
1624 return temp;
1626 else if (REG_FUNCTION_VALUE_P (orig))
1628 /* This is a reference to the function return value. If
1629 the function doesn't have a return value, error. If the
1630 mode doesn't agree, and it ain't BLKmode, make a SUBREG. */
1631 if (map->inline_target == 0)
1632 /* Must be unrolling loops or replicating code if we
1633 reach here, so return the register unchanged. */
1634 return orig;
1635 else if (GET_MODE (map->inline_target) != BLKmode
1636 && mode != GET_MODE (map->inline_target))
1637 return gen_lowpart (mode, map->inline_target);
1638 else
1639 return map->inline_target;
1641 return orig;
1643 if (map->reg_map[regno] == NULL)
1645 map->reg_map[regno] = gen_reg_rtx (mode);
1646 REG_USERVAR_P (map->reg_map[regno]) = REG_USERVAR_P (orig);
1647 REG_LOOP_TEST_P (map->reg_map[regno]) = REG_LOOP_TEST_P (orig);
1648 RTX_UNCHANGING_P (map->reg_map[regno]) = RTX_UNCHANGING_P (orig);
1649 /* A reg with REG_FUNCTION_VALUE_P true will never reach here. */
1651 if (map->regno_pointer_flag[regno])
1652 mark_reg_pointer (map->reg_map[regno],
1653 map->regno_pointer_align[regno]);
1655 return map->reg_map[regno];
1657 case SUBREG:
1658 copy = copy_rtx_and_substitute (SUBREG_REG (orig), map, for_lhs);
1659 /* SUBREG is ordinary, but don't make nested SUBREGs. */
1660 if (GET_CODE (copy) == SUBREG)
1661 return gen_rtx_SUBREG (GET_MODE (orig), SUBREG_REG (copy),
1662 SUBREG_WORD (orig) + SUBREG_WORD (copy));
1663 else if (GET_CODE (copy) == CONCAT)
1665 rtx retval = subreg_realpart_p (orig) ? XEXP (copy, 0) : XEXP (copy, 1);
1667 if (GET_MODE (retval) == GET_MODE (orig))
1668 return retval;
1669 else
1670 return gen_rtx_SUBREG (GET_MODE (orig), retval,
1671 (SUBREG_WORD (orig) %
1672 (GET_MODE_UNIT_SIZE (GET_MODE (SUBREG_REG (orig)))
1673 / (unsigned) UNITS_PER_WORD)));
1675 else
1676 return gen_rtx_SUBREG (GET_MODE (orig), copy,
1677 SUBREG_WORD (orig));
1679 case ADDRESSOF:
1680 copy = gen_rtx_ADDRESSOF (mode,
1681 copy_rtx_and_substitute (XEXP (orig, 0),
1682 map, for_lhs),
1683 0, ADDRESSOF_DECL(orig));
1684 regno = ADDRESSOF_REGNO (orig);
1685 if (map->reg_map[regno])
1686 regno = REGNO (map->reg_map[regno]);
1687 else if (regno > LAST_VIRTUAL_REGISTER)
1689 temp = XEXP (orig, 0);
1690 map->reg_map[regno] = gen_reg_rtx (GET_MODE (temp));
1691 REG_USERVAR_P (map->reg_map[regno]) = REG_USERVAR_P (temp);
1692 REG_LOOP_TEST_P (map->reg_map[regno]) = REG_LOOP_TEST_P (temp);
1693 RTX_UNCHANGING_P (map->reg_map[regno]) = RTX_UNCHANGING_P (temp);
1694 /* A reg with REG_FUNCTION_VALUE_P true will never reach here. */
1696 if (map->regno_pointer_flag[regno])
1697 mark_reg_pointer (map->reg_map[regno],
1698 map->regno_pointer_align[regno]);
1699 regno = REGNO (map->reg_map[regno]);
1701 ADDRESSOF_REGNO (copy) = regno;
1702 return copy;
1704 case USE:
1705 case CLOBBER:
1706 /* USE and CLOBBER are ordinary, but we convert (use (subreg foo))
1707 to (use foo) if the original insn didn't have a subreg.
1708 Removing the subreg distorts the VAX movstrhi pattern
1709 by changing the mode of an operand. */
1710 copy = copy_rtx_and_substitute (XEXP (orig, 0), map, code == CLOBBER);
1711 if (GET_CODE (copy) == SUBREG && GET_CODE (XEXP (orig, 0)) != SUBREG)
1712 copy = SUBREG_REG (copy);
1713 return gen_rtx_fmt_e (code, VOIDmode, copy);
1715 case CODE_LABEL:
1716 LABEL_PRESERVE_P (get_label_from_map (map, CODE_LABEL_NUMBER (orig)))
1717 = LABEL_PRESERVE_P (orig);
1718 return get_label_from_map (map, CODE_LABEL_NUMBER (orig));
1720 case LABEL_REF:
1721 copy
1722 = gen_rtx_LABEL_REF
1723 (mode,
1724 LABEL_REF_NONLOCAL_P (orig) ? XEXP (orig, 0)
1725 : get_label_from_map (map, CODE_LABEL_NUMBER (XEXP (orig, 0))));
1727 LABEL_OUTSIDE_LOOP_P (copy) = LABEL_OUTSIDE_LOOP_P (orig);
1729 /* The fact that this label was previously nonlocal does not mean
1730 it still is, so we must check if it is within the range of
1731 this function's labels. */
1732 LABEL_REF_NONLOCAL_P (copy)
1733 = (LABEL_REF_NONLOCAL_P (orig)
1734 && ! (CODE_LABEL_NUMBER (XEXP (copy, 0)) >= get_first_label_num ()
1735 && CODE_LABEL_NUMBER (XEXP (copy, 0)) < max_label_num ()));
1737 /* If we have made a nonlocal label local, it means that this
1738 inlined call will be referring to our nonlocal goto handler.
1739 So make sure we create one for this block; we normally would
1740 not since this is not otherwise considered a "call". */
1741 if (LABEL_REF_NONLOCAL_P (orig) && ! LABEL_REF_NONLOCAL_P (copy))
1742 function_call_count++;
1744 return copy;
1746 case PC:
1747 case CC0:
1748 case CONST_INT:
1749 return orig;
1751 case SYMBOL_REF:
1752 /* Symbols which represent the address of a label stored in the constant
1753 pool must be modified to point to a constant pool entry for the
1754 remapped label. Otherwise, symbols are returned unchanged. */
1755 if (CONSTANT_POOL_ADDRESS_P (orig))
1757 struct function *f = inlining ? inlining : current_function;
1758 rtx constant = get_pool_constant_for_function (f, orig);
1759 enum machine_mode const_mode = get_pool_mode_for_function (f, orig);
1760 if (inlining)
1762 rtx temp = force_const_mem (const_mode,
1763 copy_rtx_and_substitute (constant,
1764 map, 0));
1766 #if 0
1767 /* Legitimizing the address here is incorrect.
1769 Since we had a SYMBOL_REF before, we can assume it is valid
1770 to have one in this position in the insn.
1772 Also, change_address may create new registers. These
1773 registers will not have valid reg_map entries. This can
1774 cause try_constants() to fail because assumes that all
1775 registers in the rtx have valid reg_map entries, and it may
1776 end up replacing one of these new registers with junk. */
1778 if (! memory_address_p (GET_MODE (temp), XEXP (temp, 0)))
1779 temp = change_address (temp, GET_MODE (temp), XEXP (temp, 0));
1780 #endif
1782 temp = XEXP (temp, 0);
1784 #ifdef POINTERS_EXTEND_UNSIGNED
1785 if (GET_MODE (temp) != GET_MODE (orig))
1786 temp = convert_memory_address (GET_MODE (orig), temp);
1787 #endif
1788 return temp;
1790 else if (GET_CODE (constant) == LABEL_REF)
1791 return XEXP (force_const_mem
1792 (GET_MODE (orig),
1793 copy_rtx_and_substitute (constant, map, for_lhs)),
1796 else
1797 if (SYMBOL_REF_NEED_ADJUST (orig))
1799 eif_eh_map = map;
1800 return rethrow_symbol_map (orig,
1801 expand_inline_function_eh_labelmap);
1804 return orig;
1806 case CONST_DOUBLE:
1807 /* We have to make a new copy of this CONST_DOUBLE because don't want
1808 to use the old value of CONST_DOUBLE_MEM. Also, this may be a
1809 duplicate of a CONST_DOUBLE we have already seen. */
1810 if (GET_MODE_CLASS (GET_MODE (orig)) == MODE_FLOAT)
1812 REAL_VALUE_TYPE d;
1814 REAL_VALUE_FROM_CONST_DOUBLE (d, orig);
1815 return CONST_DOUBLE_FROM_REAL_VALUE (d, GET_MODE (orig));
1817 else
1818 return immed_double_const (CONST_DOUBLE_LOW (orig),
1819 CONST_DOUBLE_HIGH (orig), VOIDmode);
1821 case CONST:
1822 /* Make new constant pool entry for a constant
1823 that was in the pool of the inline function. */
1824 if (RTX_INTEGRATED_P (orig))
1825 abort ();
1826 break;
1828 case ASM_OPERANDS:
1829 /* If a single asm insn contains multiple output operands
1830 then it contains multiple ASM_OPERANDS rtx's that share operand 3.
1831 We must make sure that the copied insn continues to share it. */
1832 if (map->orig_asm_operands_vector == XVEC (orig, 3))
1834 copy = rtx_alloc (ASM_OPERANDS);
1835 copy->volatil = orig->volatil;
1836 XSTR (copy, 0) = XSTR (orig, 0);
1837 XSTR (copy, 1) = XSTR (orig, 1);
1838 XINT (copy, 2) = XINT (orig, 2);
1839 XVEC (copy, 3) = map->copy_asm_operands_vector;
1840 XVEC (copy, 4) = map->copy_asm_constraints_vector;
1841 XSTR (copy, 5) = XSTR (orig, 5);
1842 XINT (copy, 6) = XINT (orig, 6);
1843 return copy;
1845 break;
1847 case CALL:
1848 /* This is given special treatment because the first
1849 operand of a CALL is a (MEM ...) which may get
1850 forced into a register for cse. This is undesirable
1851 if function-address cse isn't wanted or if we won't do cse. */
1852 #ifndef NO_FUNCTION_CSE
1853 if (! (optimize && ! flag_no_function_cse))
1854 #endif
1855 return
1856 gen_rtx_CALL
1857 (GET_MODE (orig),
1858 gen_rtx_MEM (GET_MODE (XEXP (orig, 0)),
1859 copy_rtx_and_substitute (XEXP (XEXP (orig, 0), 0),
1860 map, 0)),
1861 copy_rtx_and_substitute (XEXP (orig, 1), map, 0));
1862 break;
1864 #if 0
1865 /* Must be ifdefed out for loop unrolling to work. */
1866 case RETURN:
1867 abort ();
1868 #endif
1870 case SET:
1871 /* If this is setting fp or ap, it means that we have a nonlocal goto.
1872 Adjust the setting by the offset of the area we made.
1873 If the nonlocal goto is into the current function,
1874 this will result in unnecessarily bad code, but should work. */
1875 if (SET_DEST (orig) == virtual_stack_vars_rtx
1876 || SET_DEST (orig) == virtual_incoming_args_rtx)
1878 /* In case a translation hasn't occurred already, make one now. */
1879 rtx equiv_reg;
1880 rtx equiv_loc;
1881 HOST_WIDE_INT loc_offset;
1883 copy_rtx_and_substitute (SET_DEST (orig), map, for_lhs);
1884 equiv_reg = map->reg_map[REGNO (SET_DEST (orig))];
1885 equiv_loc = VARRAY_CONST_EQUIV (map->const_equiv_varray,
1886 REGNO (equiv_reg)).rtx;
1887 loc_offset
1888 = GET_CODE (equiv_loc) == REG ? 0 : INTVAL (XEXP (equiv_loc, 1));
1890 return gen_rtx_SET (VOIDmode, SET_DEST (orig),
1891 force_operand
1892 (plus_constant
1893 (copy_rtx_and_substitute (SET_SRC (orig),
1894 map, 0),
1895 - loc_offset),
1896 NULL_RTX));
1898 else
1899 return gen_rtx_SET (VOIDmode,
1900 copy_rtx_and_substitute (SET_DEST (orig), map, 1),
1901 copy_rtx_and_substitute (SET_SRC (orig), map, 0));
1902 break;
1904 case MEM:
1905 if (inlining
1906 && GET_CODE (XEXP (orig, 0)) == SYMBOL_REF
1907 && CONSTANT_POOL_ADDRESS_P (XEXP (orig, 0)))
1909 enum machine_mode const_mode
1910 = get_pool_mode_for_function (inlining, XEXP (orig, 0));
1911 rtx constant
1912 = get_pool_constant_for_function (inlining, XEXP (orig, 0));
1914 constant = copy_rtx_and_substitute (constant, map, 0);
1916 /* If this was an address of a constant pool entry that itself
1917 had to be placed in the constant pool, it might not be a
1918 valid address. So the recursive call might have turned it
1919 into a register. In that case, it isn't a constant any
1920 more, so return it. This has the potential of changing a
1921 MEM into a REG, but we'll assume that it safe. */
1922 if (! CONSTANT_P (constant))
1923 return constant;
1925 return validize_mem (force_const_mem (const_mode, constant));
1928 copy = rtx_alloc (MEM);
1929 PUT_MODE (copy, mode);
1930 XEXP (copy, 0) = copy_rtx_and_substitute (XEXP (orig, 0), map, 0);
1931 MEM_COPY_ATTRIBUTES (copy, orig);
1932 MEM_ALIAS_SET (copy) = MEM_ALIAS_SET (orig);
1933 RTX_UNCHANGING_P (copy) = RTX_UNCHANGING_P (orig);
1934 return copy;
1936 default:
1937 break;
1940 copy = rtx_alloc (code);
1941 PUT_MODE (copy, mode);
1942 copy->in_struct = orig->in_struct;
1943 copy->volatil = orig->volatil;
1944 copy->unchanging = orig->unchanging;
1946 format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
1948 for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
1950 switch (*format_ptr++)
1952 case '0':
1953 /* Copy this through the wide int field; that's safest. */
1954 X0WINT (copy, i) = X0WINT (orig, i);
1955 break;
1957 case 'e':
1958 XEXP (copy, i)
1959 = copy_rtx_and_substitute (XEXP (orig, i), map, for_lhs);
1960 break;
1962 case 'u':
1963 /* Change any references to old-insns to point to the
1964 corresponding copied insns. */
1965 XEXP (copy, i) = map->insn_map[INSN_UID (XEXP (orig, i))];
1966 break;
1968 case 'E':
1969 XVEC (copy, i) = XVEC (orig, i);
1970 if (XVEC (orig, i) != NULL && XVECLEN (orig, i) != 0)
1972 XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
1973 for (j = 0; j < XVECLEN (copy, i); j++)
1974 XVECEXP (copy, i, j)
1975 = copy_rtx_and_substitute (XVECEXP (orig, i, j),
1976 map, for_lhs);
1978 break;
1980 case 'w':
1981 XWINT (copy, i) = XWINT (orig, i);
1982 break;
1984 case 'i':
1985 XINT (copy, i) = XINT (orig, i);
1986 break;
1988 case 's':
1989 XSTR (copy, i) = XSTR (orig, i);
1990 break;
1992 case 't':
1993 XTREE (copy, i) = XTREE (orig, i);
1994 break;
1996 default:
1997 abort ();
2001 if (code == ASM_OPERANDS && map->orig_asm_operands_vector == 0)
2003 map->orig_asm_operands_vector = XVEC (orig, 3);
2004 map->copy_asm_operands_vector = XVEC (copy, 3);
2005 map->copy_asm_constraints_vector = XVEC (copy, 4);
2008 return copy;
2011 /* Substitute known constant values into INSN, if that is valid. */
2013 void
2014 try_constants (insn, map)
2015 rtx insn;
2016 struct inline_remap *map;
2018 int i;
2020 map->num_sets = 0;
2022 /* First try just updating addresses, then other things. This is
2023 important when we have something like the store of a constant
2024 into memory and we can update the memory address but the machine
2025 does not support a constant source. */
2026 subst_constants (&PATTERN (insn), insn, map, 1);
2027 apply_change_group ();
2028 subst_constants (&PATTERN (insn), insn, map, 0);
2029 apply_change_group ();
2031 /* Show we don't know the value of anything stored or clobbered. */
2032 note_stores (PATTERN (insn), mark_stores, NULL);
2033 map->last_pc_value = 0;
2034 #ifdef HAVE_cc0
2035 map->last_cc0_value = 0;
2036 #endif
2038 /* Set up any constant equivalences made in this insn. */
2039 for (i = 0; i < map->num_sets; i++)
2041 if (GET_CODE (map->equiv_sets[i].dest) == REG)
2043 int regno = REGNO (map->equiv_sets[i].dest);
2045 MAYBE_EXTEND_CONST_EQUIV_VARRAY (map, regno);
2046 if (VARRAY_CONST_EQUIV (map->const_equiv_varray, regno).rtx == 0
2047 /* Following clause is a hack to make case work where GNU C++
2048 reassigns a variable to make cse work right. */
2049 || ! rtx_equal_p (VARRAY_CONST_EQUIV (map->const_equiv_varray,
2050 regno).rtx,
2051 map->equiv_sets[i].equiv))
2052 SET_CONST_EQUIV_DATA (map, map->equiv_sets[i].dest,
2053 map->equiv_sets[i].equiv, map->const_age);
2055 else if (map->equiv_sets[i].dest == pc_rtx)
2056 map->last_pc_value = map->equiv_sets[i].equiv;
2057 #ifdef HAVE_cc0
2058 else if (map->equiv_sets[i].dest == cc0_rtx)
2059 map->last_cc0_value = map->equiv_sets[i].equiv;
2060 #endif
2064 /* Substitute known constants for pseudo regs in the contents of LOC,
2065 which are part of INSN.
2066 If INSN is zero, the substitution should always be done (this is used to
2067 update DECL_RTL).
2068 These changes are taken out by try_constants if the result is not valid.
2070 Note that we are more concerned with determining when the result of a SET
2071 is a constant, for further propagation, than actually inserting constants
2072 into insns; cse will do the latter task better.
2074 This function is also used to adjust address of items previously addressed
2075 via the virtual stack variable or virtual incoming arguments registers.
2077 If MEMONLY is nonzero, only make changes inside a MEM. */
2079 static void
2080 subst_constants (loc, insn, map, memonly)
2081 rtx *loc;
2082 rtx insn;
2083 struct inline_remap *map;
2084 int memonly;
2086 rtx x = *loc;
2087 register int i, j;
2088 register enum rtx_code code;
2089 register const char *format_ptr;
2090 int num_changes = num_validated_changes ();
2091 rtx new = 0;
2092 enum machine_mode op0_mode = MAX_MACHINE_MODE;
2094 code = GET_CODE (x);
2096 switch (code)
2098 case PC:
2099 case CONST_INT:
2100 case CONST_DOUBLE:
2101 case SYMBOL_REF:
2102 case CONST:
2103 case LABEL_REF:
2104 case ADDRESS:
2105 return;
2107 #ifdef HAVE_cc0
2108 case CC0:
2109 if (! memonly)
2110 validate_change (insn, loc, map->last_cc0_value, 1);
2111 return;
2112 #endif
2114 case USE:
2115 case CLOBBER:
2116 /* The only thing we can do with a USE or CLOBBER is possibly do
2117 some substitutions in a MEM within it. */
2118 if (GET_CODE (XEXP (x, 0)) == MEM)
2119 subst_constants (&XEXP (XEXP (x, 0), 0), insn, map, 0);
2120 return;
2122 case REG:
2123 /* Substitute for parms and known constants. Don't replace
2124 hard regs used as user variables with constants. */
2125 if (! memonly)
2127 int regno = REGNO (x);
2128 struct const_equiv_data *p;
2130 if (! (regno < FIRST_PSEUDO_REGISTER && REG_USERVAR_P (x))
2131 && (size_t) regno < VARRAY_SIZE (map->const_equiv_varray)
2132 && (p = &VARRAY_CONST_EQUIV (map->const_equiv_varray, regno),
2133 p->rtx != 0)
2134 && p->age >= map->const_age)
2135 validate_change (insn, loc, p->rtx, 1);
2137 return;
2139 case SUBREG:
2140 /* SUBREG applied to something other than a reg
2141 should be treated as ordinary, since that must
2142 be a special hack and we don't know how to treat it specially.
2143 Consider for example mulsidi3 in m68k.md.
2144 Ordinary SUBREG of a REG needs this special treatment. */
2145 if (! memonly && GET_CODE (SUBREG_REG (x)) == REG)
2147 rtx inner = SUBREG_REG (x);
2148 rtx new = 0;
2150 /* We can't call subst_constants on &SUBREG_REG (x) because any
2151 constant or SUBREG wouldn't be valid inside our SUBEG. Instead,
2152 see what is inside, try to form the new SUBREG and see if that is
2153 valid. We handle two cases: extracting a full word in an
2154 integral mode and extracting the low part. */
2155 subst_constants (&inner, NULL_RTX, map, 0);
2157 if (GET_MODE_CLASS (GET_MODE (x)) == MODE_INT
2158 && GET_MODE_SIZE (GET_MODE (x)) == UNITS_PER_WORD
2159 && GET_MODE (SUBREG_REG (x)) != VOIDmode)
2160 new = operand_subword (inner, SUBREG_WORD (x), 0,
2161 GET_MODE (SUBREG_REG (x)));
2163 cancel_changes (num_changes);
2164 if (new == 0 && subreg_lowpart_p (x))
2165 new = gen_lowpart_common (GET_MODE (x), inner);
2167 if (new)
2168 validate_change (insn, loc, new, 1);
2170 return;
2172 break;
2174 case MEM:
2175 subst_constants (&XEXP (x, 0), insn, map, 0);
2177 /* If a memory address got spoiled, change it back. */
2178 if (! memonly && insn != 0 && num_validated_changes () != num_changes
2179 && ! memory_address_p (GET_MODE (x), XEXP (x, 0)))
2180 cancel_changes (num_changes);
2181 return;
2183 case SET:
2185 /* Substitute constants in our source, and in any arguments to a
2186 complex (e..g, ZERO_EXTRACT) destination, but not in the destination
2187 itself. */
2188 rtx *dest_loc = &SET_DEST (x);
2189 rtx dest = *dest_loc;
2190 rtx src, tem;
2192 subst_constants (&SET_SRC (x), insn, map, memonly);
2193 src = SET_SRC (x);
2195 while (GET_CODE (*dest_loc) == ZERO_EXTRACT
2196 || GET_CODE (*dest_loc) == SUBREG
2197 || GET_CODE (*dest_loc) == STRICT_LOW_PART)
2199 if (GET_CODE (*dest_loc) == ZERO_EXTRACT)
2201 subst_constants (&XEXP (*dest_loc, 1), insn, map, memonly);
2202 subst_constants (&XEXP (*dest_loc, 2), insn, map, memonly);
2204 dest_loc = &XEXP (*dest_loc, 0);
2207 /* Do substitute in the address of a destination in memory. */
2208 if (GET_CODE (*dest_loc) == MEM)
2209 subst_constants (&XEXP (*dest_loc, 0), insn, map, 0);
2211 /* Check for the case of DEST a SUBREG, both it and the underlying
2212 register are less than one word, and the SUBREG has the wider mode.
2213 In the case, we are really setting the underlying register to the
2214 source converted to the mode of DEST. So indicate that. */
2215 if (GET_CODE (dest) == SUBREG
2216 && GET_MODE_SIZE (GET_MODE (dest)) <= UNITS_PER_WORD
2217 && GET_MODE_SIZE (GET_MODE (SUBREG_REG (dest))) <= UNITS_PER_WORD
2218 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (dest)))
2219 <= GET_MODE_SIZE (GET_MODE (dest)))
2220 && (tem = gen_lowpart_if_possible (GET_MODE (SUBREG_REG (dest)),
2221 src)))
2222 src = tem, dest = SUBREG_REG (dest);
2224 /* If storing a recognizable value save it for later recording. */
2225 if ((map->num_sets < MAX_RECOG_OPERANDS)
2226 && (CONSTANT_P (src)
2227 || (GET_CODE (src) == REG
2228 && (REGNO (src) == VIRTUAL_INCOMING_ARGS_REGNUM
2229 || REGNO (src) == VIRTUAL_STACK_VARS_REGNUM))
2230 || (GET_CODE (src) == PLUS
2231 && GET_CODE (XEXP (src, 0)) == REG
2232 && (REGNO (XEXP (src, 0)) == VIRTUAL_INCOMING_ARGS_REGNUM
2233 || REGNO (XEXP (src, 0)) == VIRTUAL_STACK_VARS_REGNUM)
2234 && CONSTANT_P (XEXP (src, 1)))
2235 || GET_CODE (src) == COMPARE
2236 #ifdef HAVE_cc0
2237 || dest == cc0_rtx
2238 #endif
2239 || (dest == pc_rtx
2240 && (src == pc_rtx || GET_CODE (src) == RETURN
2241 || GET_CODE (src) == LABEL_REF))))
2243 /* Normally, this copy won't do anything. But, if SRC is a COMPARE
2244 it will cause us to save the COMPARE with any constants
2245 substituted, which is what we want for later. */
2246 map->equiv_sets[map->num_sets].equiv = copy_rtx (src);
2247 map->equiv_sets[map->num_sets++].dest = dest;
2250 return;
2252 default:
2253 break;
2256 format_ptr = GET_RTX_FORMAT (code);
2258 /* If the first operand is an expression, save its mode for later. */
2259 if (*format_ptr == 'e')
2260 op0_mode = GET_MODE (XEXP (x, 0));
2262 for (i = 0; i < GET_RTX_LENGTH (code); i++)
2264 switch (*format_ptr++)
2266 case '0':
2267 break;
2269 case 'e':
2270 if (XEXP (x, i))
2271 subst_constants (&XEXP (x, i), insn, map, memonly);
2272 break;
2274 case 'u':
2275 case 'i':
2276 case 's':
2277 case 'w':
2278 case 't':
2279 break;
2281 case 'E':
2282 if (XVEC (x, i) != NULL && XVECLEN (x, i) != 0)
2283 for (j = 0; j < XVECLEN (x, i); j++)
2284 subst_constants (&XVECEXP (x, i, j), insn, map, memonly);
2286 break;
2288 default:
2289 abort ();
2293 /* If this is a commutative operation, move a constant to the second
2294 operand unless the second operand is already a CONST_INT. */
2295 if (! memonly
2296 && (GET_RTX_CLASS (code) == 'c' || code == NE || code == EQ)
2297 && CONSTANT_P (XEXP (x, 0)) && GET_CODE (XEXP (x, 1)) != CONST_INT)
2299 rtx tem = XEXP (x, 0);
2300 validate_change (insn, &XEXP (x, 0), XEXP (x, 1), 1);
2301 validate_change (insn, &XEXP (x, 1), tem, 1);
2304 /* Simplify the expression in case we put in some constants. */
2305 if (! memonly)
2306 switch (GET_RTX_CLASS (code))
2308 case '1':
2309 if (op0_mode == MAX_MACHINE_MODE)
2310 abort ();
2311 new = simplify_unary_operation (code, GET_MODE (x),
2312 XEXP (x, 0), op0_mode);
2313 break;
2315 case '<':
2317 enum machine_mode op_mode = GET_MODE (XEXP (x, 0));
2319 if (op_mode == VOIDmode)
2320 op_mode = GET_MODE (XEXP (x, 1));
2321 new = simplify_relational_operation (code, op_mode,
2322 XEXP (x, 0), XEXP (x, 1));
2323 #ifdef FLOAT_STORE_FLAG_VALUE
2324 if (new != 0 && GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
2325 new = ((new == const0_rtx) ? CONST0_RTX (GET_MODE (x))
2326 : CONST_DOUBLE_FROM_REAL_VALUE (FLOAT_STORE_FLAG_VALUE,
2327 GET_MODE (x)));
2328 #endif
2329 break;
2332 case '2':
2333 case 'c':
2334 new = simplify_binary_operation (code, GET_MODE (x),
2335 XEXP (x, 0), XEXP (x, 1));
2336 break;
2338 case 'b':
2339 case '3':
2340 if (op0_mode == MAX_MACHINE_MODE)
2341 abort ();
2343 new = simplify_ternary_operation (code, GET_MODE (x), op0_mode,
2344 XEXP (x, 0), XEXP (x, 1),
2345 XEXP (x, 2));
2346 break;
2349 if (new)
2350 validate_change (insn, loc, new, 1);
2353 /* Show that register modified no longer contain known constants. We are
2354 called from note_stores with parts of the new insn. */
2356 static void
2357 mark_stores (dest, x, data)
2358 rtx dest;
2359 rtx x ATTRIBUTE_UNUSED;
2360 void *data ATTRIBUTE_UNUSED;
2362 int regno = -1;
2363 enum machine_mode mode = VOIDmode;
2365 /* DEST is always the innermost thing set, except in the case of
2366 SUBREGs of hard registers. */
2368 if (GET_CODE (dest) == REG)
2369 regno = REGNO (dest), mode = GET_MODE (dest);
2370 else if (GET_CODE (dest) == SUBREG && GET_CODE (SUBREG_REG (dest)) == REG)
2372 regno = REGNO (SUBREG_REG (dest)) + SUBREG_WORD (dest);
2373 mode = GET_MODE (SUBREG_REG (dest));
2376 if (regno >= 0)
2378 int last_reg = (regno >= FIRST_PSEUDO_REGISTER ? regno
2379 : regno + HARD_REGNO_NREGS (regno, mode) - 1);
2380 int i;
2382 /* Ignore virtual stack var or virtual arg register since those
2383 are handled separately. */
2384 if (regno != VIRTUAL_INCOMING_ARGS_REGNUM
2385 && regno != VIRTUAL_STACK_VARS_REGNUM)
2386 for (i = regno; i <= last_reg; i++)
2387 if ((size_t) i < VARRAY_SIZE (global_const_equiv_varray))
2388 VARRAY_CONST_EQUIV (global_const_equiv_varray, i).rtx = 0;
2392 /* Given a pointer to some BLOCK node, if the BLOCK_ABSTRACT_ORIGIN for the
2393 given BLOCK node is NULL, set the BLOCK_ABSTRACT_ORIGIN for the node so
2394 that it points to the node itself, thus indicating that the node is its
2395 own (abstract) origin. Additionally, if the BLOCK_ABSTRACT_ORIGIN for
2396 the given node is NULL, recursively descend the decl/block tree which
2397 it is the root of, and for each other ..._DECL or BLOCK node contained
2398 therein whose DECL_ABSTRACT_ORIGINs or BLOCK_ABSTRACT_ORIGINs are also
2399 still NULL, set *their* DECL_ABSTRACT_ORIGIN or BLOCK_ABSTRACT_ORIGIN
2400 values to point to themselves. */
2402 static void
2403 set_block_origin_self (stmt)
2404 register tree stmt;
2406 if (BLOCK_ABSTRACT_ORIGIN (stmt) == NULL_TREE)
2408 BLOCK_ABSTRACT_ORIGIN (stmt) = stmt;
2411 register tree local_decl;
2413 for (local_decl = BLOCK_VARS (stmt);
2414 local_decl != NULL_TREE;
2415 local_decl = TREE_CHAIN (local_decl))
2416 set_decl_origin_self (local_decl); /* Potential recursion. */
2420 register tree subblock;
2422 for (subblock = BLOCK_SUBBLOCKS (stmt);
2423 subblock != NULL_TREE;
2424 subblock = BLOCK_CHAIN (subblock))
2425 set_block_origin_self (subblock); /* Recurse. */
2430 /* Given a pointer to some ..._DECL node, if the DECL_ABSTRACT_ORIGIN for
2431 the given ..._DECL node is NULL, set the DECL_ABSTRACT_ORIGIN for the
2432 node to so that it points to the node itself, thus indicating that the
2433 node represents its own (abstract) origin. Additionally, if the
2434 DECL_ABSTRACT_ORIGIN for the given node is NULL, recursively descend
2435 the decl/block tree of which the given node is the root of, and for
2436 each other ..._DECL or BLOCK node contained therein whose
2437 DECL_ABSTRACT_ORIGINs or BLOCK_ABSTRACT_ORIGINs are also still NULL,
2438 set *their* DECL_ABSTRACT_ORIGIN or BLOCK_ABSTRACT_ORIGIN values to
2439 point to themselves. */
2441 static void
2442 set_decl_origin_self (decl)
2443 register tree decl;
2445 if (DECL_ABSTRACT_ORIGIN (decl) == NULL_TREE)
2447 DECL_ABSTRACT_ORIGIN (decl) = decl;
2448 if (TREE_CODE (decl) == FUNCTION_DECL)
2450 register tree arg;
2452 for (arg = DECL_ARGUMENTS (decl); arg; arg = TREE_CHAIN (arg))
2453 DECL_ABSTRACT_ORIGIN (arg) = arg;
2454 if (DECL_INITIAL (decl) != NULL_TREE
2455 && DECL_INITIAL (decl) != error_mark_node)
2456 set_block_origin_self (DECL_INITIAL (decl));
2461 /* Given a pointer to some BLOCK node, and a boolean value to set the
2462 "abstract" flags to, set that value into the BLOCK_ABSTRACT flag for
2463 the given block, and for all local decls and all local sub-blocks
2464 (recursively) which are contained therein. */
2466 static void
2467 set_block_abstract_flags (stmt, setting)
2468 register tree stmt;
2469 register int setting;
2471 register tree local_decl;
2472 register tree subblock;
2474 BLOCK_ABSTRACT (stmt) = setting;
2476 for (local_decl = BLOCK_VARS (stmt);
2477 local_decl != NULL_TREE;
2478 local_decl = TREE_CHAIN (local_decl))
2479 set_decl_abstract_flags (local_decl, setting);
2481 for (subblock = BLOCK_SUBBLOCKS (stmt);
2482 subblock != NULL_TREE;
2483 subblock = BLOCK_CHAIN (subblock))
2484 set_block_abstract_flags (subblock, setting);
2487 /* Given a pointer to some ..._DECL node, and a boolean value to set the
2488 "abstract" flags to, set that value into the DECL_ABSTRACT flag for the
2489 given decl, and (in the case where the decl is a FUNCTION_DECL) also
2490 set the abstract flags for all of the parameters, local vars, local
2491 blocks and sub-blocks (recursively) to the same setting. */
2493 void
2494 set_decl_abstract_flags (decl, setting)
2495 register tree decl;
2496 register int setting;
2498 DECL_ABSTRACT (decl) = setting;
2499 if (TREE_CODE (decl) == FUNCTION_DECL)
2501 register tree arg;
2503 for (arg = DECL_ARGUMENTS (decl); arg; arg = TREE_CHAIN (arg))
2504 DECL_ABSTRACT (arg) = setting;
2505 if (DECL_INITIAL (decl) != NULL_TREE
2506 && DECL_INITIAL (decl) != error_mark_node)
2507 set_block_abstract_flags (DECL_INITIAL (decl), setting);
2511 /* Output the assembly language code for the function FNDECL
2512 from its DECL_SAVED_INSNS. Used for inline functions that are output
2513 at end of compilation instead of where they came in the source. */
2515 void
2516 output_inline_function (fndecl)
2517 tree fndecl;
2519 struct function *curf = current_function;
2520 struct function *f = DECL_SAVED_INSNS (fndecl);
2522 current_function = f;
2523 current_function_decl = fndecl;
2524 clear_emit_caches ();
2526 /* Things we allocate from here on are part of this function, not
2527 permanent. */
2528 temporary_allocation ();
2530 set_new_last_label_num (f->inl_max_label_num);
2532 /* We must have already output DWARF debugging information for the
2533 original (abstract) inline function declaration/definition, so
2534 we want to make sure that the debugging information we generate
2535 for this special instance of the inline function refers back to
2536 the information we already generated. To make sure that happens,
2537 we simply have to set the DECL_ABSTRACT_ORIGIN for the function
2538 node (and for all of the local ..._DECL nodes which are its children)
2539 so that they all point to themselves. */
2541 set_decl_origin_self (fndecl);
2543 /* We're not deferring this any longer. */
2544 DECL_DEFER_OUTPUT (fndecl) = 0;
2546 /* We can't inline this anymore. */
2547 f->inlinable = 0;
2548 DECL_INLINE (fndecl) = 0;
2550 /* Compile this function all the way down to assembly code. */
2551 rest_of_compilation (fndecl);
2553 current_function = curf;
2554 current_function_decl = curf ? curf->decl : 0;