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