OSDN Git Service

(global_const_equiv_map_size): New variable.
[pf3gnuchains/gcc-fork.git] / gcc / integrate.c
1 /* Procedure integration for GNU CC.
2    Copyright (C) 1988, 1991, 1993 Free Software Foundation, Inc.
3    Contributed by Michael Tiemann (tiemann@cygnus.com)
4
5 This file is part of GNU CC.
6
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.
11
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.
16
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, 675 Mass Ave, Cambridge, MA 02139, USA.  */
20
21
22 #include <stdio.h>
23
24 #include "config.h"
25 #include "rtl.h"
26 #include "tree.h"
27 #include "flags.h"
28 #include "insn-config.h"
29 #include "insn-flags.h"
30 #include "expr.h"
31 #include "output.h"
32 #include "integrate.h"
33 #include "real.h"
34 #include "function.h"
35 #include "bytecode.h"
36
37 #include "obstack.h"
38 #define obstack_chunk_alloc     xmalloc
39 #define obstack_chunk_free      free
40
41 extern struct obstack *function_maybepermanent_obstack;
42
43 extern tree pushdecl ();
44 extern tree poplevel ();
45
46 /* Similar, but round to the next highest integer that meets the
47    alignment.  */
48 #define CEIL_ROUND(VALUE,ALIGN) (((VALUE) + (ALIGN) - 1) & ~((ALIGN)- 1))
49
50 /* Default max number of insns a function can have and still be inline.
51    This is overridden on RISC machines.  */
52 #ifndef INTEGRATE_THRESHOLD
53 #define INTEGRATE_THRESHOLD(DECL) \
54   (8 * (8 + list_length (DECL_ARGUMENTS (DECL))))
55 #endif
56 \f
57 /* Save any constant pool constants in an insn.  */
58 static void save_constants ();
59
60 /* Note when parameter registers are the destination of a SET.  */
61 static void note_modified_parmregs ();
62
63 /* Copy an rtx for save_for_inline_copying.  */
64 static rtx copy_for_inline ();
65
66 /* Make copies of MEMs in DECL_RTLs.  */
67 static void copy_decl_rtls ();
68
69 static tree copy_decl_tree ();
70 static tree copy_decl_list ();
71
72 static void integrate_parm_decls ();
73 static void integrate_decl_tree ();
74
75 static void subst_constants ();
76 \f
77 /* Zero if the current function (whose FUNCTION_DECL is FNDECL)
78    is safe and reasonable to integrate into other functions.
79    Nonzero means value is a warning message with a single %s
80    for the function's name.  */
81
82 char *
83 function_cannot_inline_p (fndecl)
84      register tree fndecl;
85 {
86   register rtx insn;
87   tree last = tree_last (TYPE_ARG_TYPES (TREE_TYPE (fndecl)));
88   int max_insns = INTEGRATE_THRESHOLD (fndecl);
89   register int ninsns = 0;
90   register tree parms;
91
92   /* No inlines with varargs.  `grokdeclarator' gives a warning
93      message about that if `inline' is specified.  This code
94      it put in to catch the volunteers.  */
95   if ((last && TREE_VALUE (last) != void_type_node)
96       || (DECL_ARGUMENTS (fndecl) && DECL_NAME (DECL_ARGUMENTS (fndecl))
97           && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (DECL_ARGUMENTS (fndecl))),
98                        "__builtin_va_alist")))
99     return "varargs function cannot be inline";
100
101   if (current_function_calls_alloca)
102     return "function using alloca cannot be inline";
103
104   if (current_function_contains_functions)
105     return "function with nested functions cannot be inline";
106
107   /* If its not even close, don't even look.  */
108   if (!DECL_INLINE (fndecl) && get_max_uid () > 3 * max_insns)
109     return "function too large to be inline";
110
111 #if 0
112   /* Large stacks are OK now that inlined functions can share them.  */
113   /* Don't inline functions with large stack usage,
114      since they can make other recursive functions burn up stack.  */
115   if (!DECL_INLINE (fndecl) && get_frame_size () > 100)
116     return "function stack frame for inlining";
117 #endif
118
119 #if 0
120   /* Don't inline functions which do not specify a function prototype and
121      have BLKmode argument or take the address of a parameter.  */
122   for (parms = DECL_ARGUMENTS (fndecl); parms; parms = TREE_CHAIN (parms))
123     {
124       if (TYPE_MODE (TREE_TYPE (parms)) == BLKmode)
125         TREE_ADDRESSABLE (parms) = 1;
126       if (last == NULL_TREE && TREE_ADDRESSABLE (parms))
127         return "no prototype, and parameter address used; cannot be inline";
128     }
129 #endif
130
131   /* We can't inline functions that return structures
132      the old-fashioned PCC way, copying into a static block.  */
133   if (current_function_returns_pcc_struct)
134     return "inline functions not supported for this return value type";
135
136   /* We can't inline functions that return structures of varying size.  */
137   if (int_size_in_bytes (TREE_TYPE (TREE_TYPE (fndecl))) < 0)
138     return "function with varying-size return value cannot be inline";
139
140   /* Cannot inline a function with a varying size argument.  */
141   for (parms = DECL_ARGUMENTS (fndecl); parms; parms = TREE_CHAIN (parms))
142     if (int_size_in_bytes (TREE_TYPE (parms)) < 0)
143       return "function with varying-size parameter cannot be inline";
144
145   if (!DECL_INLINE (fndecl) && get_max_uid () > max_insns)
146     {
147       for (ninsns = 0, insn = get_first_nonparm_insn (); insn && ninsns < max_insns;
148            insn = NEXT_INSN (insn))
149         {
150           if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
151             ninsns++;
152         }
153
154       if (ninsns >= max_insns)
155         return "function too large to be inline";
156     }
157
158   /* We cannot inline this function if forced_labels is non-zero.  This
159      implies that a label in this function was used as an initializer.
160      Because labels can not be duplicated, all labels in the function
161      will be renamed when it is inlined.  However, there is no way to find
162      and fix all variables initialized with addresses of labels in this
163      function, hence inlining is impossible.  */
164
165   if (forced_labels)
166     return "function with label addresses used in initializers cannot inline";
167
168   /* We cannot inline a nested function that jumps to a nonlocal label.  */
169   if (current_function_has_nonlocal_goto)
170     return "function with nonlocal goto cannot be inline";
171
172   return 0;
173 }
174 \f
175 /* Variables used within save_for_inline.  */
176
177 /* Mapping from old pseudo-register to new pseudo-registers.
178    The first element of this map is reg_map[FIRST_PSEUDO_REGISTER].
179    It is allocated in `save_for_inline' and `expand_inline_function',
180    and deallocated on exit from each of those routines.  */
181 static rtx *reg_map;
182
183 /* Mapping from old code-labels to new code-labels.
184    The first element of this map is label_map[min_labelno].
185    It is allocated in `save_for_inline' and `expand_inline_function',
186    and deallocated on exit from each of those routines.  */
187 static rtx *label_map;
188
189 /* Mapping from old insn uid's to copied insns.
190    It is allocated in `save_for_inline' and `expand_inline_function',
191    and deallocated on exit from each of those routines.  */
192 static rtx *insn_map;
193
194 /* Map pseudo reg number into the PARM_DECL for the parm living in the reg.
195    Zero for a reg that isn't a parm's home.
196    Only reg numbers less than max_parm_reg are mapped here.  */
197 static tree *parmdecl_map;
198
199 /* Keep track of first pseudo-register beyond those that are parms.  */
200 static int max_parm_reg;
201
202 /* When an insn is being copied by copy_for_inline,
203    this is nonzero if we have copied an ASM_OPERANDS.
204    In that case, it is the original input-operand vector.  */
205 static rtvec orig_asm_operands_vector;
206
207 /* When an insn is being copied by copy_for_inline,
208    this is nonzero if we have copied an ASM_OPERANDS.
209    In that case, it is the copied input-operand vector.  */
210 static rtvec copy_asm_operands_vector;
211
212 /* Likewise, this is the copied constraints vector.  */
213 static rtvec copy_asm_constraints_vector;
214
215 /* In save_for_inline, nonzero if past the parm-initialization insns.  */
216 static int in_nonparm_insns;
217 \f
218 /* Subroutine for `save_for_inline{copying,nocopy}'.  Performs initialization
219    needed to save FNDECL's insns and info for future inline expansion.  */
220    
221 static rtx
222 initialize_for_inline (fndecl, min_labelno, max_labelno, max_reg, copy)
223      tree fndecl;
224      int min_labelno;
225      int max_labelno;
226      int max_reg;
227      int copy;
228 {
229   int function_flags, i;
230   rtvec arg_vector;
231   tree parms;
232
233   /* Compute the values of any flags we must restore when inlining this.  */
234
235   function_flags
236     = (current_function_calls_alloca * FUNCTION_FLAGS_CALLS_ALLOCA
237        + current_function_calls_setjmp * FUNCTION_FLAGS_CALLS_SETJMP
238        + current_function_calls_longjmp * FUNCTION_FLAGS_CALLS_LONGJMP
239        + current_function_returns_struct * FUNCTION_FLAGS_RETURNS_STRUCT
240        + current_function_returns_pcc_struct * FUNCTION_FLAGS_RETURNS_PCC_STRUCT
241        + current_function_needs_context * FUNCTION_FLAGS_NEEDS_CONTEXT
242        + current_function_has_nonlocal_label * FUNCTION_FLAGS_HAS_NONLOCAL_LABEL
243        + current_function_returns_pointer * FUNCTION_FLAGS_RETURNS_POINTER
244        + current_function_uses_const_pool * FUNCTION_FLAGS_USES_CONST_POOL
245        + current_function_uses_pic_offset_table * FUNCTION_FLAGS_USES_PIC_OFFSET_TABLE);
246
247   /* Clear out PARMDECL_MAP.  It was allocated in the caller's frame.  */
248   bzero (parmdecl_map, max_parm_reg * sizeof (tree));
249   arg_vector = rtvec_alloc (list_length (DECL_ARGUMENTS (fndecl)));
250
251   for (parms = DECL_ARGUMENTS (fndecl), i = 0;
252        parms;
253        parms = TREE_CHAIN (parms), i++)
254     {
255       rtx p = DECL_RTL (parms);
256
257       if (GET_CODE (p) == MEM && copy)
258         {
259           /* Copy the rtl so that modifications of the addresses
260              later in compilation won't affect this arg_vector.
261              Virtual register instantiation can screw the address
262              of the rtl.  */
263           rtx new = copy_rtx (p);
264
265           /* Don't leave the old copy anywhere in this decl.  */
266           if (DECL_RTL (parms) == DECL_INCOMING_RTL (parms)
267               || (GET_CODE (DECL_RTL (parms)) == MEM
268                   && GET_CODE (DECL_INCOMING_RTL (parms)) == MEM
269                   && (XEXP (DECL_RTL (parms), 0)
270                       == XEXP (DECL_INCOMING_RTL (parms), 0))))
271             DECL_INCOMING_RTL (parms) = new;
272           DECL_RTL (parms) = new;
273         }
274
275       RTVEC_ELT (arg_vector, i) = p;
276
277       if (GET_CODE (p) == REG)
278         parmdecl_map[REGNO (p)] = parms;
279       /* This flag is cleared later
280          if the function ever modifies the value of the parm.  */
281       TREE_READONLY (parms) = 1;
282     }
283
284   /* Assume we start out in the insns that set up the parameters.  */
285   in_nonparm_insns = 0;
286
287   /* The list of DECL_SAVED_INSNS, starts off with a header which
288      contains the following information:
289
290      the first insn of the function (not including the insns that copy
291      parameters into registers).
292      the first parameter insn of the function,
293      the first label used by that function,
294      the last label used by that function,
295      the highest register number used for parameters,
296      the total number of registers used,
297      the size of the incoming stack area for parameters,
298      the number of bytes popped on return,
299      the stack slot list,
300      some flags that are used to restore compiler globals,
301      the value of current_function_outgoing_args_size,
302      the original argument vector,
303      and the original DECL_INITIAL.  */
304
305   return gen_inline_header_rtx (NULL_RTX, NULL_RTX, min_labelno, max_labelno,
306                                 max_parm_reg, max_reg,
307                                 current_function_args_size,
308                                 current_function_pops_args,
309                                 stack_slot_list, function_flags,
310                                 current_function_outgoing_args_size,
311                                 arg_vector, (rtx) DECL_INITIAL (fndecl));
312 }
313
314 /* Subroutine for `save_for_inline{copying,nocopy}'.  Finishes up the
315    things that must be done to make FNDECL expandable as an inline function.
316    HEAD contains the chain of insns to which FNDECL will expand.  */
317    
318 static void
319 finish_inline (fndecl, head)
320      tree fndecl;
321      rtx head;
322 {
323   NEXT_INSN (head) = get_first_nonparm_insn ();
324   FIRST_PARM_INSN (head) = get_insns ();
325   DECL_SAVED_INSNS (fndecl) = head;
326   DECL_FRAME_SIZE (fndecl) = get_frame_size ();
327   DECL_INLINE (fndecl) = 1;
328 }
329
330 /* Adjust the BLOCK_END_NOTE pointers in a given copied DECL tree so that
331    they all point to the new (copied) rtxs.  */
332
333 static void
334 adjust_copied_decl_tree (block)
335      register tree block;
336 {
337   register tree subblock;
338   register rtx original_end;
339
340   original_end = BLOCK_END_NOTE (block);
341   if (original_end)
342     {
343       BLOCK_END_NOTE (block) = (rtx) NOTE_SOURCE_FILE (original_end);
344       NOTE_SOURCE_FILE (original_end) = 0;
345     }
346
347   /* Process all subblocks.  */
348   for (subblock = BLOCK_SUBBLOCKS (block);
349        subblock;
350        subblock = TREE_CHAIN (subblock))
351     adjust_copied_decl_tree (subblock);
352 }
353
354 /* Make the insns and PARM_DECLs of the current function permanent
355    and record other information in DECL_SAVED_INSNS to allow inlining
356    of this function in subsequent calls.
357
358    This function is called when we are going to immediately compile
359    the insns for FNDECL.  The insns in maybepermanent_obstack cannot be
360    modified by the compilation process, so we copy all of them to
361    new storage and consider the new insns to be the insn chain to be
362    compiled.  Our caller (rest_of_compilation) saves the original
363    DECL_INITIAL and DECL_ARGUMENTS; here we copy them.  */
364
365 void
366 save_for_inline_copying (fndecl)
367      tree fndecl;
368 {
369   rtx first_insn, last_insn, insn;
370   rtx head, copy;
371   int max_labelno, min_labelno, i, len;
372   int max_reg;
373   int max_uid;
374   rtx first_nonparm_insn;
375
376   /* Make and emit a return-label if we have not already done so. 
377      Do this before recording the bounds on label numbers. */
378
379   if (return_label == 0)
380     {
381       return_label = gen_label_rtx ();
382       emit_label (return_label);
383     }
384
385   /* Get some bounds on the labels and registers used.  */
386
387   max_labelno = max_label_num ();
388   min_labelno = get_first_label_num ();
389   max_reg = max_reg_num ();
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   max_parm_reg = max_parm_reg_num ();
398   parmdecl_map = (tree *) alloca (max_parm_reg * sizeof (tree));
399
400   head = initialize_for_inline (fndecl, min_labelno, max_labelno, max_reg, 1);
401
402   if (current_function_uses_const_pool)
403     {
404       /* Replace any constant pool references with the actual constant.  We
405          will put the constants back in the copy made below.  */
406       for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
407         if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
408           {
409             save_constants (&PATTERN (insn));
410             if (REG_NOTES (insn))
411               save_constants (&REG_NOTES (insn));
412           }
413
414       /* Clear out the constant pool so that we can recreate it with the
415          copied constants below.  */
416       init_const_rtx_hash_table ();
417       clear_const_double_mem ();
418     }
419
420   max_uid = INSN_UID (head);
421
422   /* We have now allocated all that needs to be allocated permanently
423      on the rtx obstack.  Set our high-water mark, so that we
424      can free the rest of this when the time comes.  */
425
426   preserve_data ();
427
428   /* Copy the chain insns of this function.
429      Install the copied chain as the insns of this function,
430      for continued compilation;
431      the original chain is recorded as the DECL_SAVED_INSNS
432      for inlining future calls.  */
433
434   /* If there are insns that copy parms from the stack into pseudo registers,
435      those insns are not copied.  `expand_inline_function' must
436      emit the correct code to handle such things.  */
437
438   insn = get_insns ();
439   if (GET_CODE (insn) != NOTE)
440     abort ();
441   first_insn = rtx_alloc (NOTE);
442   NOTE_SOURCE_FILE (first_insn) = NOTE_SOURCE_FILE (insn);
443   NOTE_LINE_NUMBER (first_insn) = NOTE_LINE_NUMBER (insn);
444   INSN_UID (first_insn) = INSN_UID (insn);
445   PREV_INSN (first_insn) = NULL;
446   NEXT_INSN (first_insn) = NULL;
447   last_insn = first_insn;
448
449   /* Each pseudo-reg in the old insn chain must have a unique rtx in the copy.
450      Make these new rtx's now, and install them in regno_reg_rtx, so they
451      will be the official pseudo-reg rtx's for the rest of compilation.  */
452
453   reg_map = (rtx *) alloca ((max_reg + 1) * sizeof (rtx));
454
455   len = sizeof (struct rtx_def) + (GET_RTX_LENGTH (REG) - 1) * sizeof (rtunion);
456   for (i = max_reg - 1; i > LAST_VIRTUAL_REGISTER; i--)
457     reg_map[i] = (rtx)obstack_copy (function_maybepermanent_obstack,
458                                     regno_reg_rtx[i], len);
459
460   bcopy (reg_map + LAST_VIRTUAL_REGISTER + 1,
461          regno_reg_rtx + LAST_VIRTUAL_REGISTER + 1,
462          (max_reg - (LAST_VIRTUAL_REGISTER + 1)) * sizeof (rtx));
463
464   /* Likewise each label rtx must have a unique rtx as its copy.  */
465
466   label_map = (rtx *)alloca ((max_labelno - min_labelno) * sizeof (rtx));
467   label_map -= min_labelno;
468
469   for (i = min_labelno; i < max_labelno; i++)
470     label_map[i] = gen_label_rtx ();
471
472   /* Record the mapping of old insns to copied insns.  */
473
474   insn_map = (rtx *) alloca (max_uid * sizeof (rtx));
475   bzero (insn_map, max_uid * sizeof (rtx));
476
477   /* Get the insn which signals the end of parameter setup code.  */
478   first_nonparm_insn = get_first_nonparm_insn ();
479
480   /* Copy any entries in regno_reg_rtx or DECL_RTLs that reference MEM
481      (the former occurs when a variable has its address taken)
482      since these may be shared and can be changed by virtual
483      register instantiation.  DECL_RTL values for our arguments
484      have already been copied by initialize_for_inline.  */
485   for (i = LAST_VIRTUAL_REGISTER + 1; i < max_reg; i++)
486     if (GET_CODE (regno_reg_rtx[i]) == MEM)
487       XEXP (regno_reg_rtx[i], 0)
488         = copy_for_inline (XEXP (regno_reg_rtx[i], 0));
489
490   /* Copy the tree of subblocks of the function, and the decls in them.
491      We will use the copy for compiling this function, then restore the original
492      subblocks and decls for use when inlining this function.
493
494      Several parts of the compiler modify BLOCK trees.  In particular,
495      instantiate_virtual_regs will instantiate any virtual regs
496      mentioned in the DECL_RTLs of the decls, and loop
497      unrolling will replicate any BLOCK trees inside an unrolled loop.
498
499      The modified subblocks or DECL_RTLs would be incorrect for the original rtl
500      which we will use for inlining.  The rtl might even contain pseudoregs
501      whose space has been freed.  */
502
503   DECL_INITIAL (fndecl) = copy_decl_tree (DECL_INITIAL (fndecl));
504   DECL_ARGUMENTS (fndecl) = copy_decl_list (DECL_ARGUMENTS (fndecl));
505
506   /* Now copy each DECL_RTL which is a MEM,
507      so it is safe to modify their addresses.  */
508   copy_decl_rtls (DECL_INITIAL (fndecl));
509
510   /* The fndecl node acts as its own progenitor, so mark it as such.  */
511   DECL_ABSTRACT_ORIGIN (fndecl) = fndecl;
512
513   /* Now copy the chain of insns.  Do this twice.  The first copy the insn
514      itself and its body.  The second time copy of REG_NOTES.  This is because
515      a REG_NOTE may have a forward pointer to another insn.  */
516
517   for (insn = NEXT_INSN (insn); insn; insn = NEXT_INSN (insn))
518     {
519       orig_asm_operands_vector = 0;
520
521       if (insn == first_nonparm_insn)
522         in_nonparm_insns = 1;
523
524       switch (GET_CODE (insn))
525         {
526         case NOTE:
527           /* No need to keep these.  */
528           if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED)
529             continue;
530
531           copy = rtx_alloc (NOTE);
532           NOTE_LINE_NUMBER (copy) = NOTE_LINE_NUMBER (insn);
533           if (NOTE_LINE_NUMBER (insn) != NOTE_INSN_BLOCK_END)
534             NOTE_SOURCE_FILE (copy) = NOTE_SOURCE_FILE (insn);
535           else
536             {
537               NOTE_SOURCE_FILE (insn) = (char *) copy;
538               NOTE_SOURCE_FILE (copy) = 0;
539             }
540           break;
541
542         case INSN:
543         case CALL_INSN:
544         case JUMP_INSN:
545           copy = rtx_alloc (GET_CODE (insn));
546           PATTERN (copy) = copy_for_inline (PATTERN (insn));
547           INSN_CODE (copy) = -1;
548           LOG_LINKS (copy) = NULL;
549           RTX_INTEGRATED_P (copy) = RTX_INTEGRATED_P (insn);
550           break;
551
552         case CODE_LABEL:
553           copy = label_map[CODE_LABEL_NUMBER (insn)];
554           LABEL_NAME (copy) = LABEL_NAME (insn);
555           break;
556
557         case BARRIER:
558           copy = rtx_alloc (BARRIER);
559           break;
560
561         default:
562           abort ();
563         }
564       INSN_UID (copy) = INSN_UID (insn);
565       insn_map[INSN_UID (insn)] = copy;
566       NEXT_INSN (last_insn) = copy;
567       PREV_INSN (copy) = last_insn;
568       last_insn = copy;
569     }
570
571   adjust_copied_decl_tree (DECL_INITIAL (fndecl));
572
573   /* Now copy the REG_NOTES.  */
574   for (insn = NEXT_INSN (get_insns ()); insn; insn = NEXT_INSN (insn))
575     if (GET_RTX_CLASS (GET_CODE (insn)) == 'i'
576         && insn_map[INSN_UID(insn)])
577       REG_NOTES (insn_map[INSN_UID (insn)])
578         = copy_for_inline (REG_NOTES (insn));
579
580   NEXT_INSN (last_insn) = NULL;
581
582   finish_inline (fndecl, head);
583
584   set_new_first_and_last_insn (first_insn, last_insn);
585 }
586
587 /* Return a copy of a chain of nodes, chained through the TREE_CHAIN field.
588    For example, this can copy a list made of TREE_LIST nodes.  While copying,
589    for each node copied which doesn't already have is DECL_ABSTRACT_ORIGIN
590    set to some non-zero value, set the DECL_ABSTRACT_ORIGIN of the copy to
591    point to the corresponding (abstract) original node.  */
592
593 static tree
594 copy_decl_list (list)
595      tree list;
596 {
597   tree head;
598   register tree prev, next;
599
600   if (list == 0)
601     return 0;
602
603   head = prev = copy_node (list);
604   if (DECL_ABSTRACT_ORIGIN (head) == NULL_TREE)
605     DECL_ABSTRACT_ORIGIN (head) = list;
606   next = TREE_CHAIN (list);
607   while (next)
608     {
609       register tree copy;
610
611       copy = copy_node (next);
612       if (DECL_ABSTRACT_ORIGIN (copy) == NULL_TREE)
613         DECL_ABSTRACT_ORIGIN (copy) = next;
614       TREE_CHAIN (prev) = copy;
615       prev = copy;
616       next = TREE_CHAIN (next);
617     }
618   return head;
619 }
620
621 /* Make a copy of the entire tree of blocks BLOCK, and return it.  */
622
623 static tree
624 copy_decl_tree (block)
625      tree block;
626 {
627   tree t, vars, subblocks;
628
629   vars = copy_decl_list (BLOCK_VARS (block));
630   subblocks = 0;
631
632   /* Process all subblocks.  */
633   for (t = BLOCK_SUBBLOCKS (block); t; t = TREE_CHAIN (t))
634     {
635       tree copy = copy_decl_tree (t);
636       TREE_CHAIN (copy) = subblocks;
637       subblocks = copy;
638     }
639
640   t = copy_node (block);
641   BLOCK_VARS (t) = vars;
642   BLOCK_SUBBLOCKS (t) = nreverse (subblocks);
643   /* If the BLOCK being cloned is already marked as having been instantiated
644      from something else, then leave that `origin' marking alone.  Elsewise,
645      mark the clone as having originated from the BLOCK we are cloning.  */
646   if (BLOCK_ABSTRACT_ORIGIN (t) == NULL_TREE)
647     BLOCK_ABSTRACT_ORIGIN (t) = block;
648   return t;
649 }
650
651 /* Copy DECL_RTLs in all decls in the given BLOCK node.  */
652
653 static void
654 copy_decl_rtls (block)
655      tree block;
656 {
657   tree t;
658
659   for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
660     if (DECL_RTL (t) && GET_CODE (DECL_RTL (t)) == MEM)
661       DECL_RTL (t) = copy_for_inline (DECL_RTL (t));
662
663   /* Process all subblocks.  */
664   for (t = BLOCK_SUBBLOCKS (block); t; t = TREE_CHAIN (t))
665     copy_decl_rtls (t);
666 }
667
668 /* Make the insns and PARM_DECLs of the current function permanent
669    and record other information in DECL_SAVED_INSNS to allow inlining
670    of this function in subsequent calls.
671
672    This routine need not copy any insns because we are not going
673    to immediately compile the insns in the insn chain.  There
674    are two cases when we would compile the insns for FNDECL:
675    (1) when FNDECL is expanded inline, and (2) when FNDECL needs to
676    be output at the end of other compilation, because somebody took
677    its address.  In the first case, the insns of FNDECL are copied
678    as it is expanded inline, so FNDECL's saved insns are not
679    modified.  In the second case, FNDECL is used for the last time,
680    so modifying the rtl is not a problem.
681
682    ??? Actually, we do not verify that FNDECL is not inline expanded
683    by other functions which must also be written down at the end
684    of compilation.  We could set flag_no_inline to nonzero when
685    the time comes to write down such functions.  */
686
687 void
688 save_for_inline_nocopy (fndecl)
689      tree fndecl;
690 {
691   rtx insn;
692   rtx head, copy;
693   tree parms;
694   int max_labelno, min_labelno, i, len;
695   int max_reg;
696   int max_uid;
697   rtx first_nonparm_insn;
698   int function_flags;
699
700   /* Set up PARMDECL_MAP which maps pseudo-reg number to its PARM_DECL.
701      Later we set TREE_READONLY to 0 if the parm is modified inside the fn.
702      Also set up ARG_VECTOR, which holds the unmodified DECL_RTX values
703      for the parms, prior to elimination of virtual registers.
704      These values are needed for substituting parms properly.  */
705
706   max_parm_reg = max_parm_reg_num ();
707   parmdecl_map = (tree *) alloca (max_parm_reg * sizeof (tree));
708
709   /* Make and emit a return-label if we have not already done so.  */
710
711   if (return_label == 0)
712     {
713       return_label = gen_label_rtx ();
714       emit_label (return_label);
715     }
716
717   head = initialize_for_inline (fndecl, get_first_label_num (),
718                                 max_label_num (), max_reg_num (), 0);
719
720   /* If there are insns that copy parms from the stack into pseudo registers,
721      those insns are not copied.  `expand_inline_function' must
722      emit the correct code to handle such things.  */
723
724   insn = get_insns ();
725   if (GET_CODE (insn) != NOTE)
726     abort ();
727
728   /* Get the insn which signals the end of parameter setup code.  */
729   first_nonparm_insn = get_first_nonparm_insn ();
730
731   /* Now just scan the chain of insns to see what happens to our
732      PARM_DECLs.  If a PARM_DECL is used but never modified, we
733      can substitute its rtl directly when expanding inline (and
734      perform constant folding when its incoming value is constant).
735      Otherwise, we have to copy its value into a new register and track
736      the new register's life.  */
737
738   for (insn = NEXT_INSN (insn); insn; insn = NEXT_INSN (insn))
739     {
740       if (insn == first_nonparm_insn)
741         in_nonparm_insns = 1;
742
743       if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
744         {
745           if (current_function_uses_const_pool)
746             {
747               /* Replace any constant pool references with the actual constant.
748                  We will put the constant back if we need to write the
749                  function out after all.  */
750               save_constants (&PATTERN (insn));
751               if (REG_NOTES (insn))
752                 save_constants (&REG_NOTES (insn));
753             }
754
755           /* Record what interesting things happen to our parameters.  */
756           note_stores (PATTERN (insn), note_modified_parmregs);
757         }
758     }
759
760   /* We have now allocated all that needs to be allocated permanently
761      on the rtx obstack.  Set our high-water mark, so that we
762      can free the rest of this when the time comes.  */
763
764   preserve_data ();
765
766   finish_inline (fndecl, head);
767 }
768 \f
769 /* Given PX, a pointer into an insn, search for references to the constant
770    pool.  Replace each with a CONST that has the mode of the original
771    constant, contains the constant, and has RTX_INTEGRATED_P set.
772    Similarly, constant pool addresses not enclosed in a MEM are replaced
773    with an ADDRESS rtx which also gives the constant, mode, and has
774    RTX_INTEGRATED_P set.  */
775
776 static void
777 save_constants (px)
778      rtx *px;
779 {
780   rtx x;
781   int i, j;
782
783  again:
784   x = *px;
785
786   /* If this is a CONST_DOUBLE, don't try to fix things up in 
787      CONST_DOUBLE_MEM, because this is an infinite recursion.  */
788   if (GET_CODE (x) == CONST_DOUBLE)
789     return;
790   else if (GET_CODE (x) == MEM && GET_CODE (XEXP (x, 0)) == SYMBOL_REF
791            && CONSTANT_POOL_ADDRESS_P (XEXP (x,0)))
792     {
793       enum machine_mode const_mode = get_pool_mode (XEXP (x, 0));
794       rtx new = gen_rtx (CONST, const_mode, get_pool_constant (XEXP (x, 0)));
795       RTX_INTEGRATED_P (new) = 1;
796
797       /* If the MEM was in a different mode than the constant (perhaps we
798          were only looking at the low-order part), surround it with a 
799          SUBREG so we can save both modes.  */
800
801       if (GET_MODE (x) != const_mode)
802         {
803           new = gen_rtx (SUBREG, GET_MODE (x), new, 0);
804           RTX_INTEGRATED_P (new) = 1;
805         }
806
807       *px = new;
808       save_constants (&XEXP (*px, 0));
809     }
810   else if (GET_CODE (x) == SYMBOL_REF
811            && CONSTANT_POOL_ADDRESS_P (x))
812     {
813       *px = gen_rtx (ADDRESS, get_pool_mode (x), get_pool_constant (x));
814       save_constants (&XEXP (*px, 0));
815       RTX_INTEGRATED_P (*px) = 1;
816     }
817
818   else
819     {
820       char *fmt = GET_RTX_FORMAT (GET_CODE (x));
821       int len = GET_RTX_LENGTH (GET_CODE (x));
822
823       for (i = len-1; i >= 0; i--)
824         {
825           switch (fmt[i])
826             {
827             case 'E':
828               for (j = 0; j < XVECLEN (x, i); j++)
829                 save_constants (&XVECEXP (x, i, j));
830               break;
831
832             case 'e':
833               if (XEXP (x, i) == 0)
834                 continue;
835               if (i == 0)
836                 {
837                   /* Hack tail-recursion here.  */
838                   px = &XEXP (x, 0);
839                   goto again;
840                 }
841               save_constants (&XEXP (x, i));
842               break;
843             }
844         }
845     }
846 }
847 \f
848 /* Note whether a parameter is modified or not.  */
849
850 static void
851 note_modified_parmregs (reg, x)
852      rtx reg;
853      rtx x;
854 {
855   if (GET_CODE (reg) == REG && in_nonparm_insns
856       && REGNO (reg) < max_parm_reg
857       && REGNO (reg) >= FIRST_PSEUDO_REGISTER
858       && parmdecl_map[REGNO (reg)] != 0)
859     TREE_READONLY (parmdecl_map[REGNO (reg)]) = 0;
860 }
861
862 /* Copy the rtx ORIG recursively, replacing pseudo-regs and labels
863    according to `reg_map' and `label_map'.  The original rtl insns
864    will be saved for inlining; this is used to make a copy
865    which is used to finish compiling the inline function itself.
866
867    If we find a "saved" constant pool entry, one which was replaced with
868    the value of the constant, convert it back to a constant pool entry.
869    Since the pool wasn't touched, this should simply restore the old
870    address.
871
872    All other kinds of rtx are copied except those that can never be
873    changed during compilation.  */
874
875 static rtx
876 copy_for_inline (orig)
877      rtx orig;
878 {
879   register rtx x = orig;
880   register int i;
881   register enum rtx_code code;
882   register char *format_ptr;
883
884   if (x == 0)
885     return x;
886
887   code = GET_CODE (x);
888
889   /* These types may be freely shared.  */
890
891   switch (code)
892     {
893     case QUEUED:
894     case CONST_INT:
895     case SYMBOL_REF:
896     case PC:
897     case CC0:
898       return x;
899
900     case CONST_DOUBLE:
901       /* We have to make a new CONST_DOUBLE to ensure that we account for
902          it correctly.  Using the old CONST_DOUBLE_MEM data is wrong.  */
903       if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
904         {
905           REAL_VALUE_TYPE d;
906
907           REAL_VALUE_FROM_CONST_DOUBLE (d, x);
908           return immed_real_const_1 (d, GET_MODE (x));
909         }
910       else
911         return immed_double_const (CONST_DOUBLE_LOW (x), CONST_DOUBLE_HIGH (x),
912                                    VOIDmode);
913
914     case CONST:
915       /* Get constant pool entry for constant in the pool.  */
916       if (RTX_INTEGRATED_P (x))
917         return validize_mem (force_const_mem (GET_MODE (x),
918                                               copy_for_inline (XEXP (x, 0))));
919       break;
920
921     case SUBREG:
922       /* Get constant pool entry, but access in different mode.  */
923       if (RTX_INTEGRATED_P (x))
924         {
925           rtx new
926             = force_const_mem (GET_MODE (SUBREG_REG (x)),
927                                copy_for_inline (XEXP (SUBREG_REG (x), 0)));
928
929           PUT_MODE (new, GET_MODE (x));
930           return validize_mem (new);
931         }
932       break;
933
934     case ADDRESS:
935       /* If not special for constant pool error.  Else get constant pool
936          address.  */
937       if (! RTX_INTEGRATED_P (x))
938         abort ();
939
940       return XEXP (force_const_mem (GET_MODE (x),
941                                     copy_for_inline (XEXP (x, 0))), 0);
942
943     case ASM_OPERANDS:
944       /* If a single asm insn contains multiple output operands
945          then it contains multiple ASM_OPERANDS rtx's that share operand 3.
946          We must make sure that the copied insn continues to share it.  */
947       if (orig_asm_operands_vector == XVEC (orig, 3))
948         {
949           x = rtx_alloc (ASM_OPERANDS);
950           x->volatil = orig->volatil;
951           XSTR (x, 0) = XSTR (orig, 0);
952           XSTR (x, 1) = XSTR (orig, 1);
953           XINT (x, 2) = XINT (orig, 2);
954           XVEC (x, 3) = copy_asm_operands_vector;
955           XVEC (x, 4) = copy_asm_constraints_vector;
956           XSTR (x, 5) = XSTR (orig, 5);
957           XINT (x, 6) = XINT (orig, 6);
958           return x;
959         }
960       break;
961
962     case MEM:
963       /* A MEM is usually allowed to be shared if its address is constant
964          or is a constant plus one of the special registers.
965
966          We do not allow sharing of addresses that are either a special
967          register or the sum of a constant and a special register because
968          it is possible for unshare_all_rtl to copy the address, into memory
969          that won't be saved.  Although the MEM can safely be shared, and
970          won't be copied there, the address itself cannot be shared, and may
971          need to be copied. 
972
973          There are also two exceptions with constants: The first is if the
974          constant is a LABEL_REF or the sum of the LABEL_REF
975          and an integer.  This case can happen if we have an inline
976          function that supplies a constant operand to the call of another
977          inline function that uses it in a switch statement.  In this case,
978          we will be replacing the LABEL_REF, so we have to replace this MEM
979          as well.
980
981          The second case is if we have a (const (plus (address ..) ...)).
982          In that case we need to put back the address of the constant pool
983          entry.  */
984
985       if (CONSTANT_ADDRESS_P (XEXP (x, 0))
986           && GET_CODE (XEXP (x, 0)) != LABEL_REF
987           && ! (GET_CODE (XEXP (x, 0)) == CONST
988                 && (GET_CODE (XEXP (XEXP (x, 0), 0)) == PLUS
989                     && ((GET_CODE (XEXP (XEXP (XEXP (x, 0), 0), 0))
990                         == LABEL_REF)
991                         || (GET_CODE (XEXP (XEXP (XEXP (x, 0), 0), 0))
992                             == ADDRESS)))))
993         return x;
994       break;
995
996     case LABEL_REF:
997       /* If this is a non-local label, just make a new LABEL_REF.
998          Otherwise, use the new label as well.  */
999       x = gen_rtx (LABEL_REF, GET_MODE (orig),
1000                    LABEL_REF_NONLOCAL_P (orig) ? XEXP (orig, 0)
1001                    : label_map[CODE_LABEL_NUMBER (XEXP (orig, 0))]);
1002       LABEL_REF_NONLOCAL_P (x) = LABEL_REF_NONLOCAL_P (orig);
1003       LABEL_OUTSIDE_LOOP_P (x) = LABEL_OUTSIDE_LOOP_P (orig);
1004       return x;
1005
1006     case REG:
1007       if (REGNO (x) > LAST_VIRTUAL_REGISTER)
1008         return reg_map [REGNO (x)];
1009       else
1010         return x;
1011
1012     case SET:
1013       /* If a parm that gets modified lives in a pseudo-reg,
1014          clear its TREE_READONLY to prevent certain optimizations.  */
1015       {
1016         rtx dest = SET_DEST (x);
1017
1018         while (GET_CODE (dest) == STRICT_LOW_PART
1019                || GET_CODE (dest) == ZERO_EXTRACT
1020                || GET_CODE (dest) == SUBREG)
1021           dest = XEXP (dest, 0);
1022
1023         if (GET_CODE (dest) == REG
1024             && REGNO (dest) < max_parm_reg
1025             && REGNO (dest) >= FIRST_PSEUDO_REGISTER
1026             && parmdecl_map[REGNO (dest)] != 0
1027             /* The insn to load an arg pseudo from a stack slot
1028                does not count as modifying it.  */
1029             && in_nonparm_insns)
1030           TREE_READONLY (parmdecl_map[REGNO (dest)]) = 0;
1031       }
1032       break;
1033
1034 #if 0 /* This is a good idea, but here is the wrong place for it.  */
1035       /* Arrange that CONST_INTs always appear as the second operand
1036          if they appear, and that `frame_pointer_rtx' or `arg_pointer_rtx'
1037          always appear as the first.  */
1038     case PLUS:
1039       if (GET_CODE (XEXP (x, 0)) == CONST_INT
1040           || (XEXP (x, 1) == frame_pointer_rtx
1041               || (ARG_POINTER_REGNUM != FRAME_POINTER_REGNUM
1042                   && XEXP (x, 1) == arg_pointer_rtx)))
1043         {
1044           rtx t = XEXP (x, 0);
1045           XEXP (x, 0) = XEXP (x, 1);
1046           XEXP (x, 1) = t;
1047         }
1048       break;
1049 #endif
1050     }
1051
1052   /* Replace this rtx with a copy of itself.  */
1053
1054   x = rtx_alloc (code);
1055   bcopy (orig, x, (sizeof (*x) - sizeof (x->fld)
1056                    + sizeof (x->fld[0]) * GET_RTX_LENGTH (code)));
1057
1058   /* Now scan the subexpressions recursively.
1059      We can store any replaced subexpressions directly into X
1060      since we know X is not shared!  Any vectors in X
1061      must be copied if X was copied.  */
1062
1063   format_ptr = GET_RTX_FORMAT (code);
1064
1065   for (i = 0; i < GET_RTX_LENGTH (code); i++)
1066     {
1067       switch (*format_ptr++)
1068         {
1069         case 'e':
1070           XEXP (x, i) = copy_for_inline (XEXP (x, i));
1071           break;
1072
1073         case 'u':
1074           /* Change any references to old-insns to point to the
1075              corresponding copied insns.  */
1076           XEXP (x, i) = insn_map[INSN_UID (XEXP (x, i))];
1077           break;
1078
1079         case 'E':
1080           if (XVEC (x, i) != NULL && XVECLEN (x, i) != 0)
1081             {
1082               register int j;
1083
1084               XVEC (x, i) = gen_rtvec_v (XVECLEN (x, i), &XVECEXP (x, i, 0));
1085               for (j = 0; j < XVECLEN (x, i); j++)
1086                 XVECEXP (x, i, j)
1087                   = copy_for_inline (XVECEXP (x, i, j));
1088             }
1089           break;
1090         }
1091     }
1092
1093   if (code == ASM_OPERANDS && orig_asm_operands_vector == 0)
1094     {
1095       orig_asm_operands_vector = XVEC (orig, 3);
1096       copy_asm_operands_vector = XVEC (x, 3);
1097       copy_asm_constraints_vector = XVEC (x, 4);
1098     }
1099
1100   return x;
1101 }
1102
1103 /* Unfortunately, we need a global copy of const_equiv map for communication
1104    with a function called from note_stores.  Be *very* careful that this
1105    is used properly in the presence of recursion.  */
1106
1107 rtx *global_const_equiv_map;
1108 int global_const_equiv_map_size;
1109 \f
1110 #define FIXED_BASE_PLUS_P(X) \
1111   (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == CONST_INT  \
1112    && GET_CODE (XEXP (X, 0)) == REG                             \
1113    && REGNO (XEXP (X, 0)) >= FIRST_VIRTUAL_REGISTER             \
1114    && REGNO (XEXP (X, 0)) <= LAST_VIRTUAL_REGISTER)
1115
1116 /* Integrate the procedure defined by FNDECL.  Note that this function
1117    may wind up calling itself.  Since the static variables are not
1118    reentrant, we do not assign them until after the possibility
1119    of recursion is eliminated.
1120
1121    If IGNORE is nonzero, do not produce a value.
1122    Otherwise store the value in TARGET if it is nonzero and that is convenient.
1123
1124    Value is:
1125    (rtx)-1 if we could not substitute the function
1126    0 if we substituted it and it does not produce a value
1127    else an rtx for where the value is stored.  */
1128
1129 rtx
1130 expand_inline_function (fndecl, parms, target, ignore, type, structure_value_addr)
1131      tree fndecl, parms;
1132      rtx target;
1133      int ignore;
1134      tree type;
1135      rtx structure_value_addr;
1136 {
1137   tree formal, actual, block;
1138   rtx header = DECL_SAVED_INSNS (fndecl);
1139   rtx insns = FIRST_FUNCTION_INSN (header);
1140   rtx parm_insns = FIRST_PARM_INSN (header);
1141   tree *arg_trees;
1142   rtx *arg_vals;
1143   rtx insn;
1144   int max_regno;
1145   register int i;
1146   int min_labelno = FIRST_LABELNO (header);
1147   int max_labelno = LAST_LABELNO (header);
1148   int nargs;
1149   rtx local_return_label = 0;
1150   rtx loc;
1151   rtx temp;
1152   struct inline_remap *map;
1153   rtx cc0_insn = 0;
1154   rtvec arg_vector = ORIGINAL_ARG_VECTOR (header);
1155   rtx static_chain_value = 0;
1156
1157   /* Allow for equivalences of the pseudos we make for virtual fp and ap.  */
1158   max_regno = MAX_REGNUM (header) + 3;
1159   if (max_regno < FIRST_PSEUDO_REGISTER)
1160     abort ();
1161
1162   nargs = list_length (DECL_ARGUMENTS (fndecl));
1163
1164   /* We expect PARMS to have the right length; don't crash if not.  */
1165   if (list_length (parms) != nargs)
1166     return (rtx) (HOST_WIDE_INT) -1;
1167   /* Also check that the parms type match.  Since the appropriate
1168      conversions or default promotions have already been applied,
1169      the machine modes should match exactly.  */
1170   for (formal = DECL_ARGUMENTS (fndecl),
1171        actual = parms;
1172        formal;
1173        formal = TREE_CHAIN (formal),
1174        actual = TREE_CHAIN (actual))
1175     {
1176       tree arg = TREE_VALUE (actual);
1177       enum machine_mode mode = TYPE_MODE (DECL_ARG_TYPE (formal));
1178       if (mode != TYPE_MODE (TREE_TYPE (arg)))
1179         return (rtx) (HOST_WIDE_INT) -1;
1180       /* If they are block mode, the types should match exactly.
1181          They don't match exactly if TREE_TYPE (FORMAL) == ERROR_MARK_NODE,
1182          which could happen if the parameter has incomplete type.  */
1183       if (mode == BLKmode && TREE_TYPE (arg) != TREE_TYPE (formal))
1184         return (rtx) (HOST_WIDE_INT) -1;
1185     }
1186
1187   /* Make a binding contour to keep inline cleanups called at
1188      outer function-scope level from looking like they are shadowing
1189      parameter declarations.  */
1190   pushlevel (0);
1191
1192   /* Make a fresh binding contour that we can easily remove.  */
1193   pushlevel (0);
1194   expand_start_bindings (0);
1195   if (GET_CODE (parm_insns) == NOTE
1196       && NOTE_LINE_NUMBER (parm_insns) > 0)
1197     {
1198       rtx note = emit_note (NOTE_SOURCE_FILE (parm_insns),
1199                             NOTE_LINE_NUMBER (parm_insns));
1200       if (note)
1201         RTX_INTEGRATED_P (note) = 1;
1202     }
1203
1204   /* Expand the function arguments.  Do this first so that any
1205      new registers get created before we allocate the maps.  */
1206
1207   arg_vals = (rtx *) alloca (nargs * sizeof (rtx));
1208   arg_trees = (tree *) alloca (nargs * sizeof (tree));
1209
1210   for (formal = DECL_ARGUMENTS (fndecl), actual = parms, i = 0;
1211        formal;
1212        formal = TREE_CHAIN (formal), actual = TREE_CHAIN (actual), i++)
1213     {
1214       /* Actual parameter, converted to the type of the argument within the
1215          function.  */
1216       tree arg = convert (TREE_TYPE (formal), TREE_VALUE (actual));
1217       /* Mode of the variable used within the function.  */
1218       enum machine_mode mode = TYPE_MODE (TREE_TYPE (formal));
1219       /* Where parameter is located in the function.  */
1220       rtx copy;
1221
1222       /* Make sure this formal has some correspondence in the users code
1223        * before emitting any line notes for it.  */
1224       if (DECL_SOURCE_LINE (formal))
1225         {
1226           rtx note = emit_note (DECL_SOURCE_FILE (formal),
1227                                 DECL_SOURCE_LINE (formal));
1228           if (note)
1229             RTX_INTEGRATED_P (note) = 1;
1230         }
1231
1232       arg_trees[i] = arg;
1233       loc = RTVEC_ELT (arg_vector, i);
1234
1235       /* If this is an object passed by invisible reference, we copy the
1236          object into a stack slot and save its address.  If this will go
1237          into memory, we do nothing now.  Otherwise, we just expand the
1238          argument.  */
1239       if (GET_CODE (loc) == MEM && GET_CODE (XEXP (loc, 0)) == REG
1240           && REGNO (XEXP (loc, 0)) > LAST_VIRTUAL_REGISTER)
1241         {
1242           rtx stack_slot
1243             = assign_stack_temp (TYPE_MODE (TREE_TYPE (arg)),
1244                                  int_size_in_bytes (TREE_TYPE (arg)), 1);
1245
1246           store_expr (arg, stack_slot, 0);
1247
1248           arg_vals[i] = XEXP (stack_slot, 0);
1249         }
1250       else if (GET_CODE (loc) != MEM)
1251         {
1252           if (GET_MODE (loc) != TYPE_MODE (TREE_TYPE (arg)))
1253             /* The mode if LOC and ARG can differ if LOC was a variable
1254                that had its mode promoted via PROMOTED_MODE.  */
1255             arg_vals[i] = convert_modes (GET_MODE (loc),
1256                                          TYPE_MODE (TREE_TYPE (arg)),
1257                                          expand_expr (arg, NULL_RTX, mode,
1258                                                       EXPAND_SUM),
1259                                          TREE_UNSIGNED (TREE_TYPE (formal)));
1260           else
1261             arg_vals[i] = expand_expr (arg, NULL_RTX, mode, EXPAND_SUM);
1262         }
1263       else
1264         arg_vals[i] = 0;
1265
1266       if (arg_vals[i] != 0
1267           && (! TREE_READONLY (formal)
1268               /* If the parameter is not read-only, copy our argument through
1269                  a register.  Also, we cannot use ARG_VALS[I] if it overlaps
1270                  TARGET in any way.  In the inline function, they will likely
1271                  be two different pseudos, and `safe_from_p' will make all
1272                  sorts of smart assumptions about their not conflicting.
1273                  But if ARG_VALS[I] overlaps TARGET, these assumptions are
1274                  wrong, so put ARG_VALS[I] into a fresh register.  */
1275               || (target != 0
1276                   && (GET_CODE (arg_vals[i]) == REG
1277                       || GET_CODE (arg_vals[i]) == SUBREG
1278                       || GET_CODE (arg_vals[i]) == MEM)
1279                   && reg_overlap_mentioned_p (arg_vals[i], target))
1280               /* ??? We must always copy a SUBREG into a REG, because it might
1281                  get substituted into an address, and not all ports correctly
1282                  handle SUBREGs in addresses.  */
1283               || (GET_CODE (arg_vals[i]) == SUBREG)))
1284         arg_vals[i] = copy_to_mode_reg (GET_MODE (loc), arg_vals[i]);
1285     }
1286         
1287   /* Allocate the structures we use to remap things.  */
1288
1289   map = (struct inline_remap *) alloca (sizeof (struct inline_remap));
1290   map->fndecl = fndecl;
1291
1292   map->reg_map = (rtx *) alloca (max_regno * sizeof (rtx));
1293   bzero (map->reg_map, max_regno * sizeof (rtx));
1294
1295   map->label_map = (rtx *)alloca ((max_labelno - min_labelno) * sizeof (rtx));
1296   map->label_map -= min_labelno;
1297
1298   map->insn_map = (rtx *) alloca (INSN_UID (header) * sizeof (rtx));
1299   bzero (map->insn_map, INSN_UID (header) * sizeof (rtx));
1300   map->min_insnno = 0;
1301   map->max_insnno = INSN_UID (header);
1302
1303   map->integrating = 1;
1304
1305   /* const_equiv_map maps pseudos in our routine to constants, so it needs to
1306      be large enough for all our pseudos.  This is the number we are currently
1307      using plus the number in the called routine, plus 15 for each arg,
1308      five to compute the virtual frame pointer, and five for the return value.
1309      This should be enough for most cases.  We do not reference entries
1310      outside the range of the map.
1311
1312      ??? These numbers are quite arbitrary and were obtained by
1313      experimentation.  At some point, we should try to allocate the
1314      table after all the parameters are set up so we an more accurately
1315      estimate the number of pseudos we will need.  */
1316
1317   map->const_equiv_map_size
1318     = max_reg_num () + (max_regno - FIRST_PSEUDO_REGISTER) + 15 * nargs + 10;
1319
1320   map->const_equiv_map
1321     = (rtx *)alloca (map->const_equiv_map_size * sizeof (rtx));
1322   bzero (map->const_equiv_map, map->const_equiv_map_size * sizeof (rtx));
1323
1324   map->const_age_map
1325     = (unsigned *)alloca (map->const_equiv_map_size * sizeof (unsigned));
1326   bzero (map->const_age_map, map->const_equiv_map_size * sizeof (unsigned));
1327   map->const_age = 0;
1328
1329   /* Record the current insn in case we have to set up pointers to frame
1330      and argument memory blocks.  */
1331   map->insns_at_start = get_last_insn ();
1332
1333   /* Update the outgoing argument size to allow for those in the inlined
1334      function.  */
1335   if (OUTGOING_ARGS_SIZE (header) > current_function_outgoing_args_size)
1336     current_function_outgoing_args_size = OUTGOING_ARGS_SIZE (header);
1337
1338   /* If the inline function needs to make PIC references, that means
1339      that this function's PIC offset table must be used.  */
1340   if (FUNCTION_FLAGS (header) & FUNCTION_FLAGS_USES_PIC_OFFSET_TABLE)
1341     current_function_uses_pic_offset_table = 1;
1342
1343   /* If this function needs a context, set it up.  */
1344   if (FUNCTION_FLAGS (header) & FUNCTION_FLAGS_NEEDS_CONTEXT)
1345     static_chain_value = lookup_static_chain (fndecl);
1346
1347   /* Process each argument.  For each, set up things so that the function's
1348      reference to the argument will refer to the argument being passed.
1349      We only replace REG with REG here.  Any simplifications are done
1350      via const_equiv_map.
1351
1352      We make two passes:  In the first, we deal with parameters that will
1353      be placed into registers, since we need to ensure that the allocated
1354      register number fits in const_equiv_map.  Then we store all non-register
1355      parameters into their memory location.  */
1356
1357   /* Don't try to free temp stack slots here, because we may put one of the
1358      parameters into a temp stack slot.  */
1359
1360   for (i = 0; i < nargs; i++)
1361     {
1362       rtx copy = arg_vals[i];
1363
1364       loc = RTVEC_ELT (arg_vector, i);
1365
1366       /* There are three cases, each handled separately.  */
1367       if (GET_CODE (loc) == MEM && GET_CODE (XEXP (loc, 0)) == REG
1368           && REGNO (XEXP (loc, 0)) > LAST_VIRTUAL_REGISTER)
1369         {
1370           /* This must be an object passed by invisible reference (it could
1371              also be a variable-sized object, but we forbid inlining functions
1372              with variable-sized arguments).  COPY is the address of the
1373              actual value (this computation will cause it to be copied).  We
1374              map that address for the register, noting the actual address as
1375              an equivalent in case it can be substituted into the insns.  */
1376
1377           if (GET_CODE (copy) != REG)
1378             {
1379               temp = copy_addr_to_reg (copy);
1380               if ((CONSTANT_P (copy) || FIXED_BASE_PLUS_P (copy))
1381                   && REGNO (temp) < map->const_equiv_map_size)
1382                 {
1383                   map->const_equiv_map[REGNO (temp)] = copy;
1384                   map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
1385                 }
1386               copy = temp;
1387             }
1388           map->reg_map[REGNO (XEXP (loc, 0))] = copy;
1389         }
1390       else if (GET_CODE (loc) == MEM)
1391         {
1392           /* This is the case of a parameter that lives in memory.
1393              It will live in the block we allocate in the called routine's
1394              frame that simulates the incoming argument area.  Do nothing
1395              now; we will call store_expr later.  */
1396           ;
1397         }
1398       else if (GET_CODE (loc) == REG)
1399         {
1400           /* This is the good case where the parameter is in a register.
1401              If it is read-only and our argument is a constant, set up the
1402              constant equivalence.
1403
1404              If LOC is REG_USERVAR_P, the usual case, COPY must also have
1405              that flag set if it is a register.
1406
1407              Also, don't allow hard registers here; they might not be valid
1408              when substituted into insns. */
1409
1410           if ((GET_CODE (copy) != REG && GET_CODE (copy) != SUBREG)
1411               || (GET_CODE (copy) == REG && REG_USERVAR_P (loc)
1412                   && ! REG_USERVAR_P (copy))
1413               || (GET_CODE (copy) == REG
1414                   && REGNO (copy) < FIRST_PSEUDO_REGISTER))
1415             {
1416               temp = copy_to_mode_reg (GET_MODE (loc), copy);
1417               REG_USERVAR_P (temp) = REG_USERVAR_P (loc);
1418               if ((CONSTANT_P (copy) || FIXED_BASE_PLUS_P (copy))
1419                   && REGNO (temp) < map->const_equiv_map_size)
1420                 {
1421                   map->const_equiv_map[REGNO (temp)] = copy;
1422                   map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
1423                 }
1424               copy = temp;
1425             }
1426           map->reg_map[REGNO (loc)] = copy;
1427         }
1428       else if (GET_CODE (loc) == CONCAT)
1429         {
1430           /* This is the good case where the parameter is in a
1431              pair of separate pseudos.
1432              If it is read-only and our argument is a constant, set up the
1433              constant equivalence.
1434
1435              If LOC is REG_USERVAR_P, the usual case, COPY must also have
1436              that flag set if it is a register.
1437
1438              Also, don't allow hard registers here; they might not be valid
1439              when substituted into insns. */
1440           rtx locreal = gen_realpart (GET_MODE (XEXP (loc, 0)), loc);
1441           rtx locimag = gen_imagpart (GET_MODE (XEXP (loc, 0)), loc);
1442           rtx copyreal = gen_realpart (GET_MODE (locreal), copy);
1443           rtx copyimag = gen_imagpart (GET_MODE (locimag), copy);
1444
1445           if ((GET_CODE (copyreal) != REG && GET_CODE (copyreal) != SUBREG)
1446               || (GET_CODE (copyreal) == REG && REG_USERVAR_P (locreal)
1447                   && ! REG_USERVAR_P (copyreal))
1448               || (GET_CODE (copyreal) == REG
1449                   && REGNO (copyreal) < FIRST_PSEUDO_REGISTER))
1450             {
1451               temp = copy_to_mode_reg (GET_MODE (locreal), copyreal);
1452               REG_USERVAR_P (temp) = REG_USERVAR_P (locreal);
1453               if ((CONSTANT_P (copyreal) || FIXED_BASE_PLUS_P (copyreal))
1454                   && REGNO (temp) < map->const_equiv_map_size)
1455                 {
1456                   map->const_equiv_map[REGNO (temp)] = copyreal;
1457                   map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
1458                 }
1459               copyreal = temp;
1460             }
1461           map->reg_map[REGNO (locreal)] = copyreal;
1462
1463           if ((GET_CODE (copyimag) != REG && GET_CODE (copyimag) != SUBREG)
1464               || (GET_CODE (copyimag) == REG && REG_USERVAR_P (locimag)
1465                   && ! REG_USERVAR_P (copyimag))
1466               || (GET_CODE (copyimag) == REG
1467                   && REGNO (copyimag) < FIRST_PSEUDO_REGISTER))
1468             {
1469               temp = copy_to_mode_reg (GET_MODE (locimag), copyimag);
1470               REG_USERVAR_P (temp) = REG_USERVAR_P (locimag);
1471               if ((CONSTANT_P (copyimag) || FIXED_BASE_PLUS_P (copyimag))
1472                   && REGNO (temp) < map->const_equiv_map_size)
1473                 {
1474                   map->const_equiv_map[REGNO (temp)] = copyimag;
1475                   map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
1476                 }
1477               copyimag = temp;
1478             }
1479           map->reg_map[REGNO (locimag)] = copyimag;
1480         }
1481       else
1482         abort ();
1483     }
1484
1485   /* Now do the parameters that will be placed in memory.  */
1486
1487   for (formal = DECL_ARGUMENTS (fndecl), i = 0;
1488        formal; formal = TREE_CHAIN (formal), i++)
1489     {
1490       rtx copy = arg_vals[i];
1491
1492       loc = RTVEC_ELT (arg_vector, i);
1493
1494       if (GET_CODE (loc) == MEM
1495           /* Exclude case handled above.  */
1496           && ! (GET_CODE (XEXP (loc, 0)) == REG
1497                 && REGNO (XEXP (loc, 0)) > LAST_VIRTUAL_REGISTER))
1498         {
1499           rtx note = emit_note (DECL_SOURCE_FILE (formal),
1500                                 DECL_SOURCE_LINE (formal));
1501           if (note)
1502             RTX_INTEGRATED_P (note) = 1;
1503
1504           /* Compute the address in the area we reserved and store the
1505              value there.  */
1506           temp = copy_rtx_and_substitute (loc, map);
1507           subst_constants (&temp, NULL_RTX, map);
1508           apply_change_group ();
1509           if (! memory_address_p (GET_MODE (temp), XEXP (temp, 0)))
1510             temp = change_address (temp, VOIDmode, XEXP (temp, 0));
1511           store_expr (arg_trees[i], temp, 0);
1512         }
1513     }
1514
1515   /* Deal with the places that the function puts its result.
1516      We are driven by what is placed into DECL_RESULT.
1517
1518      Initially, we assume that we don't have anything special handling for
1519      REG_FUNCTION_RETURN_VALUE_P.  */
1520
1521   map->inline_target = 0;
1522   loc = DECL_RTL (DECL_RESULT (fndecl));
1523   if (TYPE_MODE (type) == VOIDmode)
1524     /* There is no return value to worry about.  */
1525     ;
1526   else if (GET_CODE (loc) == MEM)
1527     {
1528       if (! structure_value_addr || ! aggregate_value_p (DECL_RESULT (fndecl)))
1529         abort ();
1530   
1531       /* Pass the function the address in which to return a structure value.
1532          Note that a constructor can cause someone to call us with
1533          STRUCTURE_VALUE_ADDR, but the initialization takes place
1534          via the first parameter, rather than the struct return address.
1535
1536          We have two cases:  If the address is a simple register indirect,
1537          use the mapping mechanism to point that register to our structure
1538          return address.  Otherwise, store the structure return value into
1539          the place that it will be referenced from.  */
1540
1541       if (GET_CODE (XEXP (loc, 0)) == REG)
1542         {
1543           temp = force_reg (Pmode, structure_value_addr);
1544           map->reg_map[REGNO (XEXP (loc, 0))] = temp;
1545           if ((CONSTANT_P (structure_value_addr)
1546                || (GET_CODE (structure_value_addr) == PLUS
1547                    && XEXP (structure_value_addr, 0) == virtual_stack_vars_rtx
1548                    && GET_CODE (XEXP (structure_value_addr, 1)) == CONST_INT))
1549               && REGNO (temp) < map->const_equiv_map_size)
1550             {
1551               map->const_equiv_map[REGNO (temp)] = structure_value_addr;
1552               map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
1553             }
1554         }
1555       else
1556         {
1557           temp = copy_rtx_and_substitute (loc, map);
1558           subst_constants (&temp, NULL_RTX, map);
1559           apply_change_group ();
1560           emit_move_insn (temp, structure_value_addr);
1561         }
1562     }
1563   else if (ignore)
1564     /* We will ignore the result value, so don't look at its structure.
1565        Note that preparations for an aggregate return value
1566        do need to be made (above) even if it will be ignored.  */
1567     ;
1568   else if (GET_CODE (loc) == REG)
1569     {
1570       /* The function returns an object in a register and we use the return
1571          value.  Set up our target for remapping.  */
1572
1573       /* Machine mode function was declared to return.   */
1574       enum machine_mode departing_mode = TYPE_MODE (type);
1575       /* (Possibly wider) machine mode it actually computes
1576          (for the sake of callers that fail to declare it right).  */
1577       enum machine_mode arriving_mode
1578         = TYPE_MODE (TREE_TYPE (DECL_RESULT (fndecl)));
1579       rtx reg_to_map;
1580
1581       /* Don't use MEMs as direct targets because on some machines
1582          substituting a MEM for a REG makes invalid insns.
1583          Let the combiner substitute the MEM if that is valid.  */
1584       if (target == 0 || GET_CODE (target) != REG
1585           || GET_MODE (target) != departing_mode)
1586         target = gen_reg_rtx (departing_mode);
1587
1588       /* If function's value was promoted before return,
1589          avoid machine mode mismatch when we substitute INLINE_TARGET.
1590          But TARGET is what we will return to the caller.  */
1591       if (arriving_mode != departing_mode)
1592         reg_to_map = gen_rtx (SUBREG, arriving_mode, target, 0);
1593       else
1594         reg_to_map = target;
1595
1596       /* Usually, the result value is the machine's return register.
1597          Sometimes it may be a pseudo. Handle both cases.  */
1598       if (REG_FUNCTION_VALUE_P (loc))
1599         map->inline_target = reg_to_map;
1600       else
1601         map->reg_map[REGNO (loc)] = reg_to_map;
1602     }
1603
1604   /* Make new label equivalences for the labels in the called function.  */
1605   for (i = min_labelno; i < max_labelno; i++)
1606     map->label_map[i] = gen_label_rtx ();
1607
1608   /* Perform postincrements before actually calling the function.  */
1609   emit_queue ();
1610
1611   /* Clean up stack so that variables might have smaller offsets.  */
1612   do_pending_stack_adjust ();
1613
1614   /* Save a copy of the location of const_equiv_map for mark_stores, called
1615      via note_stores.  */
1616   global_const_equiv_map = map->const_equiv_map;
1617   global_const_equiv_map_size = map->const_equiv_map_size;
1618
1619   /* Now copy the insns one by one.  Do this in two passes, first the insns and
1620      then their REG_NOTES, just like save_for_inline.  */
1621
1622   /* This loop is very similar to the loop in copy_loop_body in unroll.c.  */
1623
1624   for (insn = insns; insn; insn = NEXT_INSN (insn))
1625     {
1626       rtx copy, pattern;
1627
1628       map->orig_asm_operands_vector = 0;
1629
1630       switch (GET_CODE (insn))
1631         {
1632         case INSN:
1633           pattern = PATTERN (insn);
1634           copy = 0;
1635           if (GET_CODE (pattern) == USE
1636               && GET_CODE (XEXP (pattern, 0)) == REG
1637               && REG_FUNCTION_VALUE_P (XEXP (pattern, 0)))
1638             /* The (USE (REG n)) at return from the function should
1639                be ignored since we are changing (REG n) into
1640                inline_target.  */
1641             break;
1642
1643           /* Ignore setting a function value that we don't want to use.  */
1644           if (map->inline_target == 0
1645               && GET_CODE (pattern) == SET
1646               && GET_CODE (SET_DEST (pattern)) == REG
1647               && REG_FUNCTION_VALUE_P (SET_DEST (pattern)))
1648             {
1649               if (volatile_refs_p (SET_SRC (pattern)))
1650                 {
1651                   /* If we must not delete the source,
1652                      load it into a new temporary.  */
1653                   copy = emit_insn (copy_rtx_and_substitute (pattern, map));
1654                   SET_DEST (PATTERN (copy)) 
1655                     = gen_reg_rtx (GET_MODE (SET_DEST (PATTERN (copy))));
1656                 }
1657               else
1658                 break;
1659             }
1660           /* If this is setting the static chain pseudo, set it from
1661              the value we want to give it instead.  */
1662           else if (static_chain_value != 0
1663                    && GET_CODE (pattern) == SET
1664                    && rtx_equal_p (SET_SRC (pattern),
1665                                    static_chain_incoming_rtx))
1666             {
1667               rtx newdest = copy_rtx_and_substitute (SET_DEST (pattern), map);
1668
1669               copy = emit_insn (gen_rtx (SET, VOIDmode, newdest,
1670                                          static_chain_value));
1671
1672               static_chain_value = 0;
1673             }
1674           else
1675             copy = emit_insn (copy_rtx_and_substitute (pattern, map));
1676           /* REG_NOTES will be copied later.  */
1677
1678 #ifdef HAVE_cc0
1679           /* If this insn is setting CC0, it may need to look at
1680              the insn that uses CC0 to see what type of insn it is.
1681              In that case, the call to recog via validate_change will
1682              fail.  So don't substitute constants here.  Instead,
1683              do it when we emit the following insn.
1684
1685              For example, see the pyr.md file.  That machine has signed and
1686              unsigned compares.  The compare patterns must check the
1687              following branch insn to see which what kind of compare to
1688              emit.
1689
1690              If the previous insn set CC0, substitute constants on it as
1691              well.  */
1692           if (sets_cc0_p (PATTERN (copy)) != 0)
1693             cc0_insn = copy;
1694           else
1695             {
1696               if (cc0_insn)
1697                 try_constants (cc0_insn, map);
1698               cc0_insn = 0;
1699               try_constants (copy, map);
1700             }
1701 #else
1702           try_constants (copy, map);
1703 #endif
1704           break;
1705
1706         case JUMP_INSN:
1707           if (GET_CODE (PATTERN (insn)) == RETURN)
1708             {
1709               if (local_return_label == 0)
1710                 local_return_label = gen_label_rtx ();
1711               pattern = gen_jump (local_return_label);
1712             }
1713           else
1714             pattern = copy_rtx_and_substitute (PATTERN (insn), map);
1715
1716           copy = emit_jump_insn (pattern);
1717
1718 #ifdef HAVE_cc0
1719           if (cc0_insn)
1720             try_constants (cc0_insn, map);
1721           cc0_insn = 0;
1722 #endif
1723           try_constants (copy, map);
1724
1725           /* If this used to be a conditional jump insn but whose branch
1726              direction is now know, we must do something special.  */
1727           if (condjump_p (insn) && ! simplejump_p (insn) && map->last_pc_value)
1728             {
1729 #ifdef HAVE_cc0
1730               /* The previous insn set cc0 for us.  So delete it.  */
1731               delete_insn (PREV_INSN (copy));
1732 #endif
1733
1734               /* If this is now a no-op, delete it.  */
1735               if (map->last_pc_value == pc_rtx)
1736                 {
1737                   delete_insn (copy);
1738                   copy = 0;
1739                 }
1740               else
1741                 /* Otherwise, this is unconditional jump so we must put a
1742                    BARRIER after it.  We could do some dead code elimination
1743                    here, but jump.c will do it just as well.  */
1744                 emit_barrier ();
1745             }
1746           break;
1747
1748         case CALL_INSN:
1749           pattern = copy_rtx_and_substitute (PATTERN (insn), map);
1750           copy = emit_call_insn (pattern);
1751
1752 #ifdef HAVE_cc0
1753           if (cc0_insn)
1754             try_constants (cc0_insn, map);
1755           cc0_insn = 0;
1756 #endif
1757           try_constants (copy, map);
1758
1759           /* Be lazy and assume CALL_INSNs clobber all hard registers.  */
1760           for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1761             map->const_equiv_map[i] = 0;
1762           break;
1763
1764         case CODE_LABEL:
1765           copy = emit_label (map->label_map[CODE_LABEL_NUMBER (insn)]);
1766           LABEL_NAME (copy) = LABEL_NAME (insn);
1767           map->const_age++;
1768           break;
1769
1770         case BARRIER:
1771           copy = emit_barrier ();
1772           break;
1773
1774         case NOTE:
1775           /* It is important to discard function-end and function-beg notes,
1776              so we have only one of each in the current function.
1777              Also, NOTE_INSN_DELETED notes aren't useful (save_for_inline
1778              deleted these in the copy used for continuing compilation,
1779              not the copy used for inlining).  */
1780           if (NOTE_LINE_NUMBER (insn) != NOTE_INSN_FUNCTION_END
1781               && NOTE_LINE_NUMBER (insn) != NOTE_INSN_FUNCTION_BEG
1782               && NOTE_LINE_NUMBER (insn) != NOTE_INSN_DELETED)
1783             copy = emit_note (NOTE_SOURCE_FILE (insn), NOTE_LINE_NUMBER (insn));
1784           else
1785             copy = 0;
1786           break;
1787
1788         default:
1789           abort ();
1790           break;
1791         }
1792
1793       if (copy)
1794         RTX_INTEGRATED_P (copy) = 1;
1795
1796       map->insn_map[INSN_UID (insn)] = copy;
1797     }
1798
1799   /* Now copy the REG_NOTES.  Increment const_age, so that only constants
1800      from parameters can be substituted in.  These are the only ones that
1801      are valid across the entire function.  */
1802   map->const_age++;
1803   for (insn = insns; insn; insn = NEXT_INSN (insn))
1804     if (GET_RTX_CLASS (GET_CODE (insn)) == 'i'
1805         && map->insn_map[INSN_UID (insn)]
1806         && REG_NOTES (insn))
1807       {
1808         rtx tem = copy_rtx_and_substitute (REG_NOTES (insn), map);
1809         /* We must also do subst_constants, in case one of our parameters
1810            has const type and constant value.  */
1811         subst_constants (&tem, NULL_RTX, map);
1812         apply_change_group ();
1813         REG_NOTES (map->insn_map[INSN_UID (insn)]) = tem;
1814       }
1815
1816   if (local_return_label)
1817     emit_label (local_return_label);
1818
1819   /* Make copies of the decls of the symbols in the inline function, so that
1820      the copies of the variables get declared in the current function.  Set
1821      up things so that lookup_static_chain knows that to interpret registers
1822      in SAVE_EXPRs for TYPE_SIZEs as local.  */
1823
1824   inline_function_decl = fndecl;
1825   integrate_parm_decls (DECL_ARGUMENTS (fndecl), map, arg_vector);
1826   integrate_decl_tree ((tree) ORIGINAL_DECL_INITIAL (header), 0, map);
1827   inline_function_decl = 0;
1828
1829   /* End the scope containing the copied formal parameter variables
1830      and copied LABEL_DECLs.  */
1831
1832   expand_end_bindings (getdecls (), 1, 1);
1833   block = poplevel (1, 1, 0);
1834   BLOCK_ABSTRACT_ORIGIN (block) = (DECL_ABSTRACT_ORIGIN (fndecl) == NULL
1835                                    ? fndecl : DECL_ABSTRACT_ORIGIN (fndecl));
1836   poplevel (0, 0, 0);
1837   emit_line_note (input_filename, lineno);
1838
1839   if (structure_value_addr)
1840     {
1841       target = gen_rtx (MEM, TYPE_MODE (type),
1842                         memory_address (TYPE_MODE (type), structure_value_addr));
1843       MEM_IN_STRUCT_P (target) = 1;
1844     }
1845   return target;
1846 }
1847 \f
1848 /* Given a chain of PARM_DECLs, ARGS, copy each decl into a VAR_DECL,
1849    push all of those decls and give each one the corresponding home.  */
1850
1851 static void
1852 integrate_parm_decls (args, map, arg_vector)
1853      tree args;
1854      struct inline_remap *map;
1855      rtvec arg_vector;
1856 {
1857   register tree tail;
1858   register int i;
1859
1860   for (tail = args, i = 0; tail; tail = TREE_CHAIN (tail), i++)
1861     {
1862       register tree decl = build_decl (VAR_DECL, DECL_NAME (tail),
1863                                        TREE_TYPE (tail));
1864       rtx new_decl_rtl
1865         = copy_rtx_and_substitute (RTVEC_ELT (arg_vector, i), map);
1866
1867       DECL_ARG_TYPE (decl) = DECL_ARG_TYPE (tail);
1868       /* We really should be setting DECL_INCOMING_RTL to something reasonable
1869          here, but that's going to require some more work.  */
1870       /* DECL_INCOMING_RTL (decl) = ?; */
1871       /* These args would always appear unused, if not for this.  */
1872       TREE_USED (decl) = 1;
1873       /* Prevent warning for shadowing with these.  */
1874       DECL_ABSTRACT_ORIGIN (decl) = tail;
1875       pushdecl (decl);
1876       /* Fully instantiate the address with the equivalent form so that the
1877          debugging information contains the actual register, instead of the
1878          virtual register.   Do this by not passing an insn to
1879          subst_constants.  */
1880       subst_constants (&new_decl_rtl, NULL_RTX, map);
1881       apply_change_group ();
1882       DECL_RTL (decl) = new_decl_rtl;
1883     }
1884 }
1885
1886 /* Given a BLOCK node LET, push decls and levels so as to construct in the
1887    current function a tree of contexts isomorphic to the one that is given.
1888
1889    LEVEL indicates how far down into the BLOCK tree is the node we are
1890    currently traversing.  It is always zero except for recursive calls.
1891
1892    MAP, if nonzero, is a pointer to an inline_remap map which indicates how
1893    registers used in the DECL_RTL field should be remapped.  If it is zero,
1894    no mapping is necessary.  */
1895
1896 static void
1897 integrate_decl_tree (let, level, map)
1898      tree let;
1899      int level;
1900      struct inline_remap *map;
1901 {
1902   tree t, node;
1903
1904   if (level > 0)
1905     pushlevel (0);
1906   
1907   for (t = BLOCK_VARS (let); t; t = TREE_CHAIN (t))
1908     {
1909       tree d = build_decl (TREE_CODE (t), DECL_NAME (t), TREE_TYPE (t));
1910       DECL_SOURCE_LINE (d) = DECL_SOURCE_LINE (t);
1911       DECL_SOURCE_FILE (d) = DECL_SOURCE_FILE (t);
1912       if (DECL_RTL (t) != 0)
1913         {
1914           DECL_RTL (d) = copy_rtx_and_substitute (DECL_RTL (t), map);
1915           /* Fully instantiate the address with the equivalent form so that the
1916              debugging information contains the actual register, instead of the
1917              virtual register.   Do this by not passing an insn to
1918              subst_constants.  */
1919           subst_constants (&DECL_RTL (d), NULL_RTX, map);
1920           apply_change_group ();
1921         }
1922       else if (DECL_RTL (t))
1923         DECL_RTL (d) = copy_rtx (DECL_RTL (t));
1924       DECL_EXTERNAL (d) = DECL_EXTERNAL (t);
1925       TREE_STATIC (d) = TREE_STATIC (t);
1926       TREE_PUBLIC (d) = TREE_PUBLIC (t);
1927       TREE_CONSTANT (d) = TREE_CONSTANT (t);
1928       TREE_ADDRESSABLE (d) = TREE_ADDRESSABLE (t);
1929       TREE_READONLY (d) = TREE_READONLY (t);
1930       TREE_SIDE_EFFECTS (d) = TREE_SIDE_EFFECTS (t);
1931       /* These args would always appear unused, if not for this.  */
1932       TREE_USED (d) = 1;
1933       /* Prevent warning for shadowing with these.  */
1934       DECL_ABSTRACT_ORIGIN (d) = t;
1935       pushdecl (d);
1936     }
1937
1938   for (t = BLOCK_SUBBLOCKS (let); t; t = TREE_CHAIN (t))
1939     integrate_decl_tree (t, level + 1, map);
1940
1941   if (level > 0)
1942     {
1943       node = poplevel (1, 0, 0);
1944       if (node)
1945         {
1946           TREE_USED (node) = TREE_USED (let);
1947           BLOCK_ABSTRACT_ORIGIN (node) = let;
1948         }
1949     }
1950 }
1951 \f
1952 /* Create a new copy of an rtx.
1953    Recursively copies the operands of the rtx,
1954    except for those few rtx codes that are sharable.
1955
1956    We always return an rtx that is similar to that incoming rtx, with the
1957    exception of possibly changing a REG to a SUBREG or vice versa.  No
1958    rtl is ever emitted.
1959
1960    Handle constants that need to be placed in the constant pool by
1961    calling `force_const_mem'.  */
1962
1963 rtx
1964 copy_rtx_and_substitute (orig, map)
1965      register rtx orig;
1966      struct inline_remap *map;
1967 {
1968   register rtx copy, temp;
1969   register int i, j;
1970   register RTX_CODE code;
1971   register enum machine_mode mode;
1972   register char *format_ptr;
1973   int regno;
1974
1975   if (orig == 0)
1976     return 0;
1977
1978   code = GET_CODE (orig);
1979   mode = GET_MODE (orig);
1980
1981   switch (code)
1982     {
1983     case REG:
1984       /* If the stack pointer register shows up, it must be part of
1985          stack-adjustments (*not* because we eliminated the frame pointer!).
1986          Small hard registers are returned as-is.  Pseudo-registers
1987          go through their `reg_map'.  */
1988       regno = REGNO (orig);
1989       if (regno <= LAST_VIRTUAL_REGISTER)
1990         {
1991           /* Some hard registers are also mapped,
1992              but others are not translated.  */
1993           if (map->reg_map[regno] != 0)
1994             return map->reg_map[regno];
1995
1996           /* If this is the virtual frame pointer, make space in current
1997              function's stack frame for the stack frame of the inline function.
1998
1999              Copy the address of this area into a pseudo.  Map
2000              virtual_stack_vars_rtx to this pseudo and set up a constant
2001              equivalence for it to be the address.  This will substitute the
2002              address into insns where it can be substituted and use the new
2003              pseudo where it can't.  */
2004           if (regno == VIRTUAL_STACK_VARS_REGNUM)
2005             {
2006               rtx loc, seq;
2007               int size = DECL_FRAME_SIZE (map->fndecl);
2008               int rounded;
2009
2010               start_sequence ();
2011               loc = assign_stack_temp (BLKmode, size, 1);
2012               loc = XEXP (loc, 0);
2013 #ifdef FRAME_GROWS_DOWNWARD
2014               /* In this case, virtual_stack_vars_rtx points to one byte
2015                  higher than the top of the frame area.  So compute the offset
2016                  to one byte higher than our substitute frame.
2017                  Keep the fake frame pointer aligned like a real one.  */
2018               rounded = CEIL_ROUND (size, BIGGEST_ALIGNMENT / BITS_PER_UNIT);
2019               loc = plus_constant (loc, rounded);
2020 #endif
2021               map->reg_map[regno] = temp
2022                 = force_reg (Pmode, force_operand (loc, NULL_RTX));
2023
2024               if (REGNO (temp) < map->const_equiv_map_size)
2025                 {
2026                   map->const_equiv_map[REGNO (temp)] = loc;
2027                   map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
2028                 }
2029
2030               seq = gen_sequence ();
2031               end_sequence ();
2032               emit_insn_after (seq, map->insns_at_start);
2033               return temp;
2034             }
2035           else if (regno == VIRTUAL_INCOMING_ARGS_REGNUM)
2036             {
2037               /* Do the same for a block to contain any arguments referenced
2038                  in memory. */
2039               rtx loc, seq;
2040               int size = FUNCTION_ARGS_SIZE (DECL_SAVED_INSNS (map->fndecl));
2041
2042               start_sequence ();
2043               loc = assign_stack_temp (BLKmode, size, 1);
2044               loc = XEXP (loc, 0);
2045               /* When arguments grow downward, the virtual incoming 
2046                  args pointer points to the top of the argument block,
2047                  so the remapped location better do the same. */
2048 #ifdef ARGS_GROW_DOWNWARD
2049               loc = plus_constant (loc, size);
2050 #endif
2051               map->reg_map[regno] = temp
2052                 = force_reg (Pmode, force_operand (loc, NULL_RTX));
2053
2054               if (REGNO (temp) < map->const_equiv_map_size)
2055                 {
2056                   map->const_equiv_map[REGNO (temp)] = loc;
2057                   map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
2058                 }
2059
2060               seq = gen_sequence ();
2061               end_sequence ();
2062               emit_insn_after (seq, map->insns_at_start);
2063               return temp;
2064             }
2065           else if (REG_FUNCTION_VALUE_P (orig))
2066             {
2067               /* This is a reference to the function return value.  If
2068                  the function doesn't have a return value, error.  If the
2069                  mode doesn't agree, make a SUBREG.  */
2070               if (map->inline_target == 0)
2071                 /* Must be unrolling loops or replicating code if we
2072                    reach here, so return the register unchanged.  */
2073                 return orig;
2074               else if (mode != GET_MODE (map->inline_target))
2075                 return gen_lowpart (mode, map->inline_target);
2076               else
2077                 return map->inline_target;
2078             }
2079           return orig;
2080         }
2081       if (map->reg_map[regno] == NULL)
2082         {
2083           map->reg_map[regno] = gen_reg_rtx (mode);
2084           REG_USERVAR_P (map->reg_map[regno]) = REG_USERVAR_P (orig);
2085           REG_LOOP_TEST_P (map->reg_map[regno]) = REG_LOOP_TEST_P (orig);
2086           RTX_UNCHANGING_P (map->reg_map[regno]) = RTX_UNCHANGING_P (orig);
2087           /* A reg with REG_FUNCTION_VALUE_P true will never reach here.  */
2088         }
2089       return map->reg_map[regno];
2090
2091     case SUBREG:
2092       copy = copy_rtx_and_substitute (SUBREG_REG (orig), map);
2093       /* SUBREG is ordinary, but don't make nested SUBREGs.  */
2094       if (GET_CODE (copy) == SUBREG)
2095         return gen_rtx (SUBREG, GET_MODE (orig), SUBREG_REG (copy),
2096                         SUBREG_WORD (orig) + SUBREG_WORD (copy));
2097       else if (GET_CODE (copy) == CONCAT)
2098         return (subreg_lowpart_p (orig) ? XEXP (copy, 0) : XEXP (copy, 1));
2099       else
2100         return gen_rtx (SUBREG, GET_MODE (orig), copy,
2101                         SUBREG_WORD (orig));
2102
2103     case USE:
2104     case CLOBBER:
2105       /* USE and CLOBBER are ordinary, but we convert (use (subreg foo))
2106          to (use foo) if the original insn didn't have a subreg.
2107          Removing the subreg distorts the VAX movstrhi pattern
2108          by changing the mode of an operand.  */
2109       copy = copy_rtx_and_substitute (XEXP (orig, 0), map);
2110       if (GET_CODE (copy) == SUBREG && GET_CODE (XEXP (orig, 0)) != SUBREG)
2111         copy = SUBREG_REG (copy);
2112       return gen_rtx (code, VOIDmode, copy);
2113
2114     case CODE_LABEL:
2115       LABEL_PRESERVE_P (map->label_map[CODE_LABEL_NUMBER (orig)])
2116         = LABEL_PRESERVE_P (orig);
2117       return map->label_map[CODE_LABEL_NUMBER (orig)];
2118
2119     case LABEL_REF:
2120       copy = gen_rtx (LABEL_REF, mode,
2121                       LABEL_REF_NONLOCAL_P (orig) ? XEXP (orig, 0)
2122                       : map->label_map[CODE_LABEL_NUMBER (XEXP (orig, 0))]);
2123       LABEL_OUTSIDE_LOOP_P (copy) = LABEL_OUTSIDE_LOOP_P (orig);
2124
2125       /* The fact that this label was previously nonlocal does not mean
2126          it still is, so we must check if it is within the range of
2127          this function's labels.  */
2128       LABEL_REF_NONLOCAL_P (copy)
2129         = (LABEL_REF_NONLOCAL_P (orig)
2130            && ! (CODE_LABEL_NUMBER (XEXP (copy, 0)) >= get_first_label_num ()
2131                  && CODE_LABEL_NUMBER (XEXP (copy, 0)) < max_label_num ()));
2132
2133       /* If we have made a nonlocal label local, it means that this
2134          inlined call will be refering to our nonlocal goto handler.
2135          So make sure we create one for this block; we normally would
2136          not since this is not otherwise considered a "call".  */
2137       if (LABEL_REF_NONLOCAL_P (orig) && ! LABEL_REF_NONLOCAL_P (copy))
2138         function_call_count++;
2139
2140       return copy;
2141
2142     case PC:
2143     case CC0:
2144     case CONST_INT:
2145       return orig;
2146
2147     case SYMBOL_REF:
2148       /* Symbols which represent the address of a label stored in the constant
2149          pool must be modified to point to a constant pool entry for the
2150          remapped label.  Otherwise, symbols are returned unchanged.  */
2151       if (CONSTANT_POOL_ADDRESS_P (orig))
2152         {
2153           rtx constant = get_pool_constant (orig);
2154           if (GET_CODE (constant) == LABEL_REF)
2155             return XEXP (force_const_mem (Pmode, 
2156                                           copy_rtx_and_substitute (constant,
2157                                                                    map)),
2158                          0);
2159         }
2160
2161       return orig;
2162
2163     case CONST_DOUBLE:
2164       /* We have to make a new copy of this CONST_DOUBLE because don't want
2165          to use the old value of CONST_DOUBLE_MEM.  Also, this may be a
2166          duplicate of a CONST_DOUBLE we have already seen.  */
2167       if (GET_MODE_CLASS (GET_MODE (orig)) == MODE_FLOAT)
2168         {
2169           REAL_VALUE_TYPE d;
2170
2171           REAL_VALUE_FROM_CONST_DOUBLE (d, orig);
2172           return immed_real_const_1 (d, GET_MODE (orig));
2173         }
2174       else
2175         return immed_double_const (CONST_DOUBLE_LOW (orig),
2176                                    CONST_DOUBLE_HIGH (orig), VOIDmode);
2177
2178     case CONST:
2179       /* Make new constant pool entry for a constant
2180          that was in the pool of the inline function.  */
2181       if (RTX_INTEGRATED_P (orig))
2182         {
2183           /* If this was an address of a constant pool entry that itself
2184              had to be placed in the constant pool, it might not be a
2185              valid address.  So the recursive call below might turn it
2186              into a register.  In that case, it isn't a constant any
2187              more, so return it.  This has the potential of changing a
2188              MEM into a REG, but we'll assume that it safe.  */
2189           temp = copy_rtx_and_substitute (XEXP (orig, 0), map);
2190           if (! CONSTANT_P (temp))
2191             return temp;
2192           return validize_mem (force_const_mem (GET_MODE (orig), temp));
2193         }
2194       break;
2195
2196     case ADDRESS:
2197       /* If from constant pool address, make new constant pool entry and
2198          return its address.  */
2199       if (! RTX_INTEGRATED_P (orig))
2200         abort ();
2201
2202       temp = force_const_mem (GET_MODE (orig),
2203                               copy_rtx_and_substitute (XEXP (orig, 0), map));
2204
2205 #if 0
2206       /* Legitimizing the address here is incorrect.
2207
2208          The only ADDRESS rtx's that can reach here are ones created by
2209          save_constants.  Hence the operand of the ADDRESS is always legal
2210          in this position of the instruction, since the original rtx without
2211          the ADDRESS was legal.
2212
2213          The reason we don't legitimize the address here is that on the
2214          Sparc, the caller may have a (high ...) surrounding this ADDRESS.
2215          This code forces the operand of the address to a register, which
2216          fails because we can not take the HIGH part of a register.
2217
2218          Also, change_address may create new registers.  These registers
2219          will not have valid reg_map entries.  This can cause try_constants()
2220          to fail because assumes that all registers in the rtx have valid
2221          reg_map entries, and it may end up replacing one of these new
2222          registers with junk. */
2223
2224       if (! memory_address_p (GET_MODE (temp), XEXP (temp, 0)))
2225         temp = change_address (temp, GET_MODE (temp), XEXP (temp, 0));
2226 #endif
2227
2228       return XEXP (temp, 0);
2229
2230     case ASM_OPERANDS:
2231       /* If a single asm insn contains multiple output operands
2232          then it contains multiple ASM_OPERANDS rtx's that share operand 3.
2233          We must make sure that the copied insn continues to share it.  */
2234       if (map->orig_asm_operands_vector == XVEC (orig, 3))
2235         {
2236           copy = rtx_alloc (ASM_OPERANDS);
2237           copy->volatil = orig->volatil;
2238           XSTR (copy, 0) = XSTR (orig, 0);
2239           XSTR (copy, 1) = XSTR (orig, 1);
2240           XINT (copy, 2) = XINT (orig, 2);
2241           XVEC (copy, 3) = map->copy_asm_operands_vector;
2242           XVEC (copy, 4) = map->copy_asm_constraints_vector;
2243           XSTR (copy, 5) = XSTR (orig, 5);
2244           XINT (copy, 6) = XINT (orig, 6);
2245           return copy;
2246         }
2247       break;
2248
2249     case CALL:
2250       /* This is given special treatment because the first
2251          operand of a CALL is a (MEM ...) which may get
2252          forced into a register for cse.  This is undesirable
2253          if function-address cse isn't wanted or if we won't do cse.  */
2254 #ifndef NO_FUNCTION_CSE
2255       if (! (optimize && ! flag_no_function_cse))
2256 #endif
2257         return gen_rtx (CALL, GET_MODE (orig),
2258                         gen_rtx (MEM, GET_MODE (XEXP (orig, 0)),
2259                                  copy_rtx_and_substitute (XEXP (XEXP (orig, 0), 0), map)),
2260                         copy_rtx_and_substitute (XEXP (orig, 1), map));
2261       break;
2262
2263 #if 0
2264       /* Must be ifdefed out for loop unrolling to work.  */
2265     case RETURN:
2266       abort ();
2267 #endif
2268
2269     case SET:
2270       /* If this is setting fp or ap, it means that we have a nonlocal goto.
2271          Don't alter that.
2272          If the nonlocal goto is into the current function,
2273          this will result in unnecessarily bad code, but should work.  */
2274       if (SET_DEST (orig) == virtual_stack_vars_rtx
2275           || SET_DEST (orig) == virtual_incoming_args_rtx)
2276         return gen_rtx (SET, VOIDmode, SET_DEST (orig),
2277                         copy_rtx_and_substitute (SET_SRC (orig), map));
2278       break;
2279
2280     case MEM:
2281       copy = rtx_alloc (MEM);
2282       PUT_MODE (copy, mode);
2283       XEXP (copy, 0) = copy_rtx_and_substitute (XEXP (orig, 0), map);
2284       MEM_IN_STRUCT_P (copy) = MEM_IN_STRUCT_P (orig);
2285       MEM_VOLATILE_P (copy) = MEM_VOLATILE_P (orig);
2286
2287       /* If doing function inlining, this MEM might not be const in the
2288          function that it is being inlined into, and thus may not be
2289          unchanging after function inlining.  Constant pool references are
2290          handled elsewhere, so this doesn't lose RTX_UNCHANGING_P bits
2291          for them.  */
2292       if (! map->integrating)
2293         RTX_UNCHANGING_P (copy) = RTX_UNCHANGING_P (orig);
2294
2295       return copy;
2296     }
2297
2298   copy = rtx_alloc (code);
2299   PUT_MODE (copy, mode);
2300   copy->in_struct = orig->in_struct;
2301   copy->volatil = orig->volatil;
2302   copy->unchanging = orig->unchanging;
2303
2304   format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
2305
2306   for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
2307     {
2308       switch (*format_ptr++)
2309         {
2310         case '0':
2311           break;
2312
2313         case 'e':
2314           XEXP (copy, i) = copy_rtx_and_substitute (XEXP (orig, i), map);
2315           break;
2316
2317         case 'u':
2318           /* Change any references to old-insns to point to the
2319              corresponding copied insns.  */
2320           XEXP (copy, i) = map->insn_map[INSN_UID (XEXP (orig, i))];
2321           break;
2322
2323         case 'E':
2324           XVEC (copy, i) = XVEC (orig, i);
2325           if (XVEC (orig, i) != NULL && XVECLEN (orig, i) != 0)
2326             {
2327               XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
2328               for (j = 0; j < XVECLEN (copy, i); j++)
2329                 XVECEXP (copy, i, j)
2330                   = copy_rtx_and_substitute (XVECEXP (orig, i, j), map);
2331             }
2332           break;
2333
2334         case 'w':
2335           XWINT (copy, i) = XWINT (orig, i);
2336           break;
2337
2338         case 'i':
2339           XINT (copy, i) = XINT (orig, i);
2340           break;
2341
2342         case 's':
2343           XSTR (copy, i) = XSTR (orig, i);
2344           break;
2345
2346         default:
2347           abort ();
2348         }
2349     }
2350
2351   if (code == ASM_OPERANDS && map->orig_asm_operands_vector == 0)
2352     {
2353       map->orig_asm_operands_vector = XVEC (orig, 3);
2354       map->copy_asm_operands_vector = XVEC (copy, 3);
2355       map->copy_asm_constraints_vector = XVEC (copy, 4);
2356     }
2357
2358   return copy;
2359 }
2360 \f
2361 /* Substitute known constant values into INSN, if that is valid.  */
2362
2363 void
2364 try_constants (insn, map)
2365      rtx insn;
2366      struct inline_remap *map;
2367 {
2368   int i;
2369
2370   map->num_sets = 0;
2371   subst_constants (&PATTERN (insn), insn, map);
2372
2373   /* Apply the changes if they are valid; otherwise discard them.  */
2374   apply_change_group ();
2375
2376   /* Show we don't know the value of anything stored or clobbered.  */
2377   note_stores (PATTERN (insn), mark_stores);
2378   map->last_pc_value = 0;
2379 #ifdef HAVE_cc0
2380   map->last_cc0_value = 0;
2381 #endif
2382
2383   /* Set up any constant equivalences made in this insn.  */
2384   for (i = 0; i < map->num_sets; i++)
2385     {
2386       if (GET_CODE (map->equiv_sets[i].dest) == REG)
2387         {
2388           int regno = REGNO (map->equiv_sets[i].dest);
2389
2390           if (regno < map->const_equiv_map_size
2391               && (map->const_equiv_map[regno] == 0
2392                   /* Following clause is a hack to make case work where GNU C++
2393                      reassigns a variable to make cse work right.  */
2394                   || ! rtx_equal_p (map->const_equiv_map[regno],
2395                                     map->equiv_sets[i].equiv)))
2396             {
2397               map->const_equiv_map[regno] = map->equiv_sets[i].equiv;
2398               map->const_age_map[regno] = map->const_age;
2399             }
2400         }
2401       else if (map->equiv_sets[i].dest == pc_rtx)
2402         map->last_pc_value = map->equiv_sets[i].equiv;
2403 #ifdef HAVE_cc0
2404       else if (map->equiv_sets[i].dest == cc0_rtx)
2405         map->last_cc0_value = map->equiv_sets[i].equiv;
2406 #endif
2407     }
2408 }
2409 \f
2410 /* Substitute known constants for pseudo regs in the contents of LOC,
2411    which are part of INSN.
2412    If INSN is zero, the substitution should always be done (this is used to
2413    update DECL_RTL).
2414    These changes are taken out by try_constants if the result is not valid.
2415
2416    Note that we are more concerned with determining when the result of a SET
2417    is a constant, for further propagation, than actually inserting constants
2418    into insns; cse will do the latter task better.
2419
2420    This function is also used to adjust address of items previously addressed
2421    via the virtual stack variable or virtual incoming arguments registers.  */
2422
2423 static void
2424 subst_constants (loc, insn, map)
2425      rtx *loc;
2426      rtx insn;
2427      struct inline_remap *map;
2428 {
2429   rtx x = *loc;
2430   register int i;
2431   register enum rtx_code code;
2432   register char *format_ptr;
2433   int num_changes = num_validated_changes ();
2434   rtx new = 0;
2435   enum machine_mode op0_mode;
2436
2437   code = GET_CODE (x);
2438
2439   switch (code)
2440     {
2441     case PC:
2442     case CONST_INT:
2443     case CONST_DOUBLE:
2444     case SYMBOL_REF:
2445     case CONST:
2446     case LABEL_REF:
2447     case ADDRESS:
2448       return;
2449
2450 #ifdef HAVE_cc0
2451     case CC0:
2452       validate_change (insn, loc, map->last_cc0_value, 1);
2453       return;
2454 #endif
2455
2456     case USE:
2457     case CLOBBER:
2458       /* The only thing we can do with a USE or CLOBBER is possibly do
2459          some substitutions in a MEM within it.  */
2460       if (GET_CODE (XEXP (x, 0)) == MEM)
2461         subst_constants (&XEXP (XEXP (x, 0), 0), insn, map);
2462       return;
2463
2464     case REG:
2465       /* Substitute for parms and known constants.  Don't replace
2466          hard regs used as user variables with constants.  */
2467       {
2468         int regno = REGNO (x);
2469
2470         if (! (regno < FIRST_PSEUDO_REGISTER && REG_USERVAR_P (x))
2471             && regno < map->const_equiv_map_size
2472             && map->const_equiv_map[regno] != 0
2473             && map->const_age_map[regno] >= map->const_age)
2474           validate_change (insn, loc, map->const_equiv_map[regno], 1);
2475         return;
2476       }
2477
2478     case SUBREG:
2479       /* SUBREG applied to something other than a reg
2480          should be treated as ordinary, since that must
2481          be a special hack and we don't know how to treat it specially.
2482          Consider for example mulsidi3 in m68k.md.
2483          Ordinary SUBREG of a REG needs this special treatment.  */
2484       if (GET_CODE (SUBREG_REG (x)) == REG)
2485         {
2486           rtx inner = SUBREG_REG (x);
2487           rtx new = 0;
2488
2489           /* We can't call subst_constants on &SUBREG_REG (x) because any
2490              constant or SUBREG wouldn't be valid inside our SUBEG.  Instead,
2491              see what is inside, try to form the new SUBREG and see if that is
2492              valid.  We handle two cases: extracting a full word in an 
2493              integral mode and extracting the low part.  */
2494           subst_constants (&inner, NULL_RTX, map);
2495
2496           if (GET_MODE_CLASS (GET_MODE (x)) == MODE_INT
2497               && GET_MODE_SIZE (GET_MODE (x)) == UNITS_PER_WORD
2498               && GET_MODE (SUBREG_REG (x)) != VOIDmode)
2499             new = operand_subword (inner, SUBREG_WORD (x), 0,
2500                                    GET_MODE (SUBREG_REG (x)));
2501
2502           if (new == 0 && subreg_lowpart_p (x))
2503             new = gen_lowpart_common (GET_MODE (x), inner);
2504
2505           if (new)
2506             validate_change (insn, loc, new, 1);
2507
2508           return;
2509         }
2510       break;
2511
2512     case MEM:
2513       subst_constants (&XEXP (x, 0), insn, map);
2514
2515       /* If a memory address got spoiled, change it back.  */
2516       if (insn != 0 && num_validated_changes () != num_changes
2517           && !memory_address_p (GET_MODE (x), XEXP (x, 0)))
2518         cancel_changes (num_changes);
2519       return;
2520
2521     case SET:
2522       {
2523         /* Substitute constants in our source, and in any arguments to a
2524            complex (e..g, ZERO_EXTRACT) destination, but not in the destination
2525            itself.  */
2526         rtx *dest_loc = &SET_DEST (x);
2527         rtx dest = *dest_loc;
2528         rtx src, tem;
2529
2530         subst_constants (&SET_SRC (x), insn, map);
2531         src = SET_SRC (x);
2532
2533         while (GET_CODE (*dest_loc) == ZERO_EXTRACT
2534                /* By convention, we always use ZERO_EXTRACT in the dest.  */
2535 /*             || GET_CODE (*dest_loc) == SIGN_EXTRACT */
2536                || GET_CODE (*dest_loc) == SUBREG
2537                || GET_CODE (*dest_loc) == STRICT_LOW_PART)
2538           {
2539             if (GET_CODE (*dest_loc) == ZERO_EXTRACT)
2540               {
2541                 subst_constants (&XEXP (*dest_loc, 1), insn, map);
2542                 subst_constants (&XEXP (*dest_loc, 2), insn, map);
2543               }
2544             dest_loc = &XEXP (*dest_loc, 0);
2545           }
2546
2547         /* Do substitute in the address of a destination in memory.  */
2548         if (GET_CODE (*dest_loc) == MEM)
2549           subst_constants (&XEXP (*dest_loc, 0), insn, map);
2550
2551         /* Check for the case of DEST a SUBREG, both it and the underlying
2552            register are less than one word, and the SUBREG has the wider mode.
2553            In the case, we are really setting the underlying register to the
2554            source converted to the mode of DEST.  So indicate that.  */
2555         if (GET_CODE (dest) == SUBREG
2556             && GET_MODE_SIZE (GET_MODE (dest)) <= UNITS_PER_WORD
2557             && GET_MODE_SIZE (GET_MODE (SUBREG_REG (dest))) <= UNITS_PER_WORD
2558             && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (dest)))
2559                       <= GET_MODE_SIZE (GET_MODE (dest)))
2560             && (tem = gen_lowpart_if_possible (GET_MODE (SUBREG_REG (dest)),
2561                                                src)))
2562           src = tem, dest = SUBREG_REG (dest);
2563
2564         /* If storing a recognizable value save it for later recording.  */
2565         if ((map->num_sets < MAX_RECOG_OPERANDS)
2566             && (CONSTANT_P (src)
2567                 || (GET_CODE (src) == PLUS
2568                     && GET_CODE (XEXP (src, 0)) == REG
2569                     && REGNO (XEXP (src, 0)) >= FIRST_VIRTUAL_REGISTER
2570                     && REGNO (XEXP (src, 0)) <= LAST_VIRTUAL_REGISTER
2571                     && CONSTANT_P (XEXP (src, 1)))
2572                 || GET_CODE (src) == COMPARE
2573 #ifdef HAVE_cc0
2574                 || dest == cc0_rtx
2575 #endif
2576                 || (dest == pc_rtx
2577                     && (src == pc_rtx || GET_CODE (src) == RETURN
2578                         || GET_CODE (src) == LABEL_REF))))
2579           {
2580             /* Normally, this copy won't do anything.  But, if SRC is a COMPARE
2581                it will cause us to save the COMPARE with any constants
2582                substituted, which is what we want for later.  */
2583             map->equiv_sets[map->num_sets].equiv = copy_rtx (src);
2584             map->equiv_sets[map->num_sets++].dest = dest;
2585           }
2586
2587         return;
2588       }
2589     }
2590
2591   format_ptr = GET_RTX_FORMAT (code);
2592   
2593   /* If the first operand is an expression, save its mode for later.  */
2594   if (*format_ptr == 'e')
2595     op0_mode = GET_MODE (XEXP (x, 0));
2596
2597   for (i = 0; i < GET_RTX_LENGTH (code); i++)
2598     {
2599       switch (*format_ptr++)
2600         {
2601         case '0':
2602           break;
2603
2604         case 'e':
2605           if (XEXP (x, i))
2606             subst_constants (&XEXP (x, i), insn, map);
2607           break;
2608
2609         case 'u':
2610         case 'i':
2611         case 's':
2612         case 'w':
2613           break;
2614
2615         case 'E':
2616           if (XVEC (x, i) != NULL && XVECLEN (x, i) != 0)
2617             {
2618               int j;
2619               for (j = 0; j < XVECLEN (x, i); j++)
2620                 subst_constants (&XVECEXP (x, i, j), insn, map);
2621             }
2622           break;
2623
2624         default:
2625           abort ();
2626         }
2627     }
2628
2629   /* If this is a commutative operation, move a constant to the second
2630      operand unless the second operand is already a CONST_INT.  */
2631   if ((GET_RTX_CLASS (code) == 'c' || code == NE || code == EQ)
2632       && CONSTANT_P (XEXP (x, 0)) && GET_CODE (XEXP (x, 1)) != CONST_INT)
2633     {
2634       rtx tem = XEXP (x, 0);
2635       validate_change (insn, &XEXP (x, 0), XEXP (x, 1), 1);
2636       validate_change (insn, &XEXP (x, 1), tem, 1);
2637     }
2638
2639   /* Simplify the expression in case we put in some constants.  */
2640   switch (GET_RTX_CLASS (code))
2641     {
2642     case '1':
2643       new = simplify_unary_operation (code, GET_MODE (x),
2644                                       XEXP (x, 0), op0_mode);
2645       break;
2646
2647     case '<':
2648       {
2649         enum machine_mode op_mode = GET_MODE (XEXP (x, 0));
2650         if (op_mode == VOIDmode)
2651           op_mode = GET_MODE (XEXP (x, 1));
2652         new = simplify_relational_operation (code, op_mode,
2653                                              XEXP (x, 0), XEXP (x, 1));
2654 #ifdef FLOAT_STORE_FLAG_VALUE
2655         if (new != 0 && GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
2656           new = ((new == const0_rtx) ? CONST0_RTX (GET_MODE (x))
2657                  : immed_real_const_1 (FLOAT_STORE_FLAG_VALUE, GET_MODE (x)));
2658 #endif
2659         break;
2660       }
2661
2662     case '2':
2663     case 'c':
2664       new = simplify_binary_operation (code, GET_MODE (x),
2665                                        XEXP (x, 0), XEXP (x, 1));
2666       break;
2667
2668     case 'b':
2669     case '3':
2670       new = simplify_ternary_operation (code, GET_MODE (x), op0_mode,
2671                                         XEXP (x, 0), XEXP (x, 1), XEXP (x, 2));
2672       break;
2673     }
2674
2675   if (new)
2676     validate_change (insn, loc, new, 1);
2677 }
2678
2679 /* Show that register modified no longer contain known constants.  We are
2680    called from note_stores with parts of the new insn.  */
2681
2682 void
2683 mark_stores (dest, x)
2684      rtx dest;
2685      rtx x;
2686 {
2687   int regno = -1;
2688   enum machine_mode mode;
2689
2690   /* DEST is always the innermost thing set, except in the case of
2691      SUBREGs of hard registers.  */
2692
2693   if (GET_CODE (dest) == REG)
2694     regno = REGNO (dest), mode = GET_MODE (dest);
2695   else if (GET_CODE (dest) == SUBREG && GET_CODE (SUBREG_REG (dest)) == REG)
2696     {
2697       regno = REGNO (SUBREG_REG (dest)) + SUBREG_WORD (dest);
2698       mode = GET_MODE (SUBREG_REG (dest));
2699     }
2700
2701   if (regno >= 0)
2702     {
2703       int last_reg = (regno >= FIRST_PSEUDO_REGISTER ? regno
2704                       : regno + HARD_REGNO_NREGS (regno, mode) - 1);
2705       int i;
2706
2707       for (i = regno; i <= last_reg; i++)
2708         if (i < global_const_equiv_map_size)
2709           global_const_equiv_map[i] = 0;
2710     }
2711 }
2712 \f
2713 /* If any CONST expressions with RTX_INTEGRATED_P are present in the rtx
2714    pointed to by PX, they represent constants in the constant pool.
2715    Replace these with a new memory reference obtained from force_const_mem.
2716    Similarly, ADDRESS expressions with RTX_INTEGRATED_P represent the
2717    address of a constant pool entry.  Replace them with the address of
2718    a new constant pool entry obtained from force_const_mem.  */
2719
2720 static void
2721 restore_constants (px)
2722      rtx *px;
2723 {
2724   rtx x = *px;
2725   int i, j;
2726   char *fmt;
2727
2728   if (x == 0)
2729     return;
2730
2731   if (GET_CODE (x) == CONST_DOUBLE)
2732     {
2733       /* We have to make a new CONST_DOUBLE to ensure that we account for
2734          it correctly.  Using the old CONST_DOUBLE_MEM data is wrong.  */
2735       if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
2736         {
2737           REAL_VALUE_TYPE d;
2738
2739           REAL_VALUE_FROM_CONST_DOUBLE (d, x);
2740           *px = immed_real_const_1 (d, GET_MODE (x));
2741         }
2742       else
2743         *px = immed_double_const (CONST_DOUBLE_LOW (x), CONST_DOUBLE_HIGH (x),
2744                                   VOIDmode);
2745     }
2746
2747   else if (RTX_INTEGRATED_P (x) && GET_CODE (x) == CONST)
2748     {
2749       restore_constants (&XEXP (x, 0));
2750       *px = validize_mem (force_const_mem (GET_MODE (x), XEXP (x, 0)));
2751     }
2752   else if (RTX_INTEGRATED_P (x) && GET_CODE (x) == SUBREG)
2753     {
2754       /* This must be (subreg/i:M1 (const/i:M2 ...) 0).  */
2755       rtx new = XEXP (SUBREG_REG (x), 0);
2756
2757       restore_constants (&new);
2758       new = force_const_mem (GET_MODE (SUBREG_REG (x)), new);
2759       PUT_MODE (new, GET_MODE (x));
2760       *px = validize_mem (new);
2761     }
2762   else if (RTX_INTEGRATED_P (x) && GET_CODE (x) == ADDRESS)
2763     {
2764       restore_constants (&XEXP (x, 0));
2765       *px = XEXP (force_const_mem (GET_MODE (x), XEXP (x, 0)), 0);
2766     }
2767   else
2768     {
2769       fmt = GET_RTX_FORMAT (GET_CODE (x));
2770       for (i = 0; i < GET_RTX_LENGTH (GET_CODE (x)); i++)
2771         {
2772           switch (*fmt++)
2773             {
2774             case 'E':
2775               for (j = 0; j < XVECLEN (x, i); j++)
2776                 restore_constants (&XVECEXP (x, i, j));
2777               break;
2778
2779             case 'e':
2780               restore_constants (&XEXP (x, i));
2781               break;
2782             }
2783         }
2784     }
2785 }
2786 \f
2787 /* Given a pointer to some BLOCK node, if the BLOCK_ABSTRACT_ORIGIN for the
2788    given BLOCK node is NULL, set the BLOCK_ABSTRACT_ORIGIN for the node so
2789    that it points to the node itself, thus indicating that the node is its
2790    own (abstract) origin.  Additionally, if the BLOCK_ABSTRACT_ORIGIN for
2791    the given node is NULL, recursively descend the decl/block tree which
2792    it is the root of, and for each other ..._DECL or BLOCK node contained
2793    therein whose DECL_ABSTRACT_ORIGINs or BLOCK_ABSTRACT_ORIGINs are also
2794    still NULL, set *their* DECL_ABSTRACT_ORIGIN or BLOCK_ABSTRACT_ORIGIN
2795    values to point to themselves.  */
2796
2797 static void set_decl_origin_self ();
2798
2799 static void
2800 set_block_origin_self (stmt)
2801      register tree stmt;
2802 {
2803   if (BLOCK_ABSTRACT_ORIGIN (stmt) == NULL_TREE)
2804     {
2805       BLOCK_ABSTRACT_ORIGIN (stmt) = stmt;
2806
2807       {
2808         register tree local_decl;
2809
2810         for (local_decl = BLOCK_VARS (stmt);
2811              local_decl != NULL_TREE;
2812              local_decl = TREE_CHAIN (local_decl))
2813           set_decl_origin_self (local_decl);    /* Potential recursion.  */
2814       }
2815
2816       {
2817         register tree subblock;
2818
2819         for (subblock = BLOCK_SUBBLOCKS (stmt);
2820              subblock != NULL_TREE;
2821              subblock = BLOCK_CHAIN (subblock))
2822           set_block_origin_self (subblock);     /* Recurse.  */
2823       }
2824     }
2825 }
2826
2827 /* Given a pointer to some ..._DECL node, if the DECL_ABSTRACT_ORIGIN for
2828    the given ..._DECL node is NULL, set the DECL_ABSTRACT_ORIGIN for the
2829    node to so that it points to the node itself, thus indicating that the
2830    node represents its own (abstract) origin.  Additionally, if the
2831    DECL_ABSTRACT_ORIGIN for the given node is NULL, recursively descend
2832    the decl/block tree of which the given node is the root of, and for
2833    each other ..._DECL or BLOCK node contained therein whose
2834    DECL_ABSTRACT_ORIGINs or BLOCK_ABSTRACT_ORIGINs are also still NULL,
2835    set *their* DECL_ABSTRACT_ORIGIN or BLOCK_ABSTRACT_ORIGIN values to
2836    point to themselves.  */
2837
2838 static void
2839 set_decl_origin_self (decl)
2840      register tree decl;
2841 {
2842   if (DECL_ABSTRACT_ORIGIN (decl) == NULL_TREE)
2843     {
2844       DECL_ABSTRACT_ORIGIN (decl) = decl;
2845       if (TREE_CODE (decl) == FUNCTION_DECL)
2846         {
2847           register tree arg;
2848
2849           for (arg = DECL_ARGUMENTS (decl); arg; arg = TREE_CHAIN (arg))
2850             DECL_ABSTRACT_ORIGIN (arg) = arg;
2851           if (DECL_INITIAL (decl) != NULL_TREE)
2852             set_block_origin_self (DECL_INITIAL (decl));
2853         }
2854     }
2855 }
2856 \f
2857 /* Given a pointer to some BLOCK node, and a boolean value to set the
2858    "abstract" flags to, set that value into the BLOCK_ABSTRACT flag for
2859    the given block, and for all local decls and all local sub-blocks
2860    (recursively) which are contained therein.  */
2861
2862 void set_decl_abstract_flags ();
2863
2864 static void
2865 set_block_abstract_flags (stmt, setting)
2866      register tree stmt;
2867      register int setting;
2868 {
2869   BLOCK_ABSTRACT (stmt) = setting;
2870
2871   {
2872     register tree local_decl;
2873
2874     for (local_decl = BLOCK_VARS (stmt);
2875          local_decl != NULL_TREE;
2876          local_decl = TREE_CHAIN (local_decl))
2877       set_decl_abstract_flags (local_decl, setting);
2878   }
2879
2880   {
2881     register tree subblock;
2882
2883     for (subblock = BLOCK_SUBBLOCKS (stmt);
2884          subblock != NULL_TREE;
2885          subblock = BLOCK_CHAIN (subblock))
2886       set_block_abstract_flags (subblock, setting);
2887   }
2888 }
2889
2890 /* Given a pointer to some ..._DECL node, and a boolean value to set the
2891    "abstract" flags to, set that value into the DECL_ABSTRACT flag for the
2892    given decl, and (in the case where the decl is a FUNCTION_DECL) also
2893    set the abstract flags for all of the parameters, local vars, local
2894    blocks and sub-blocks (recursively) to the same setting.  */
2895
2896 void
2897 set_decl_abstract_flags (decl, setting)
2898      register tree decl;
2899      register int setting;
2900 {
2901   DECL_ABSTRACT (decl) = setting;
2902   if (TREE_CODE (decl) == FUNCTION_DECL)
2903     {
2904       register tree arg;
2905
2906       for (arg = DECL_ARGUMENTS (decl); arg; arg = TREE_CHAIN (arg))
2907         DECL_ABSTRACT (arg) = setting;
2908       if (DECL_INITIAL (decl) != NULL_TREE)
2909         set_block_abstract_flags (DECL_INITIAL (decl), setting);
2910     }
2911 }
2912 \f
2913 /* Output the assembly language code for the function FNDECL
2914    from its DECL_SAVED_INSNS.  Used for inline functions that are output
2915    at end of compilation instead of where they came in the source.  */
2916
2917 void
2918 output_inline_function (fndecl)
2919      tree fndecl;
2920 {
2921   rtx head;
2922   rtx last;
2923
2924   if (output_bytecode)
2925     {
2926       warning ("`inline' ignored for bytecode output");
2927       return;
2928     }
2929
2930   head = DECL_SAVED_INSNS (fndecl);
2931   current_function_decl = fndecl;
2932
2933   /* This call is only used to initialize global variables.  */
2934   init_function_start (fndecl, "lossage", 1);
2935
2936   /* Redo parameter determinations in case the FUNCTION_...
2937      macros took machine-specific actions that need to be redone.  */
2938   assign_parms (fndecl, 1);
2939
2940   /* Set stack frame size.  */
2941   assign_stack_local (BLKmode, DECL_FRAME_SIZE (fndecl), 0);
2942
2943   restore_reg_data (FIRST_PARM_INSN (head));
2944
2945   stack_slot_list = STACK_SLOT_LIST (head);
2946
2947   if (FUNCTION_FLAGS (head) & FUNCTION_FLAGS_CALLS_ALLOCA)
2948     current_function_calls_alloca = 1;
2949
2950   if (FUNCTION_FLAGS (head) & FUNCTION_FLAGS_CALLS_SETJMP)
2951     current_function_calls_setjmp = 1;
2952
2953   if (FUNCTION_FLAGS (head) & FUNCTION_FLAGS_CALLS_LONGJMP)
2954     current_function_calls_longjmp = 1;
2955
2956   if (FUNCTION_FLAGS (head) & FUNCTION_FLAGS_RETURNS_STRUCT)
2957     current_function_returns_struct = 1;
2958
2959   if (FUNCTION_FLAGS (head) & FUNCTION_FLAGS_RETURNS_PCC_STRUCT)
2960     current_function_returns_pcc_struct = 1;
2961
2962   if (FUNCTION_FLAGS (head) & FUNCTION_FLAGS_NEEDS_CONTEXT)
2963     current_function_needs_context = 1;
2964
2965   if (FUNCTION_FLAGS (head) & FUNCTION_FLAGS_HAS_NONLOCAL_LABEL)
2966     current_function_has_nonlocal_label = 1;
2967
2968   if (FUNCTION_FLAGS (head) & FUNCTION_FLAGS_RETURNS_POINTER)
2969     current_function_returns_pointer = 1;
2970
2971   if (FUNCTION_FLAGS (head) & FUNCTION_FLAGS_USES_CONST_POOL)
2972     current_function_uses_const_pool = 1;
2973
2974   if (FUNCTION_FLAGS (head) & FUNCTION_FLAGS_USES_PIC_OFFSET_TABLE)
2975     current_function_uses_pic_offset_table = 1;
2976
2977   current_function_outgoing_args_size = OUTGOING_ARGS_SIZE (head);
2978   current_function_pops_args = POPS_ARGS (head);
2979
2980   /* There is no need to output a return label again.  */
2981   return_label = 0;
2982
2983   expand_function_end (DECL_SOURCE_FILE (fndecl), DECL_SOURCE_LINE (fndecl));
2984
2985   /* Find last insn and rebuild the constant pool.  */
2986   for (last = FIRST_PARM_INSN (head);
2987        NEXT_INSN (last); last = NEXT_INSN (last))
2988     {
2989       if (GET_RTX_CLASS (GET_CODE (last)) == 'i')
2990         {
2991           restore_constants (&PATTERN (last));
2992           restore_constants (&REG_NOTES (last));
2993         }
2994     }
2995
2996   set_new_first_and_last_insn (FIRST_PARM_INSN (head), last);
2997   set_new_first_and_last_label_num (FIRST_LABELNO (head), LAST_LABELNO (head));
2998
2999   /* We must have already output DWARF debugging information for the
3000      original (abstract) inline function declaration/definition, so
3001      we want to make sure that the debugging information we generate
3002      for this special instance of the inline function refers back to
3003      the information we already generated.  To make sure that happens,
3004      we simply have to set the DECL_ABSTRACT_ORIGIN for the function
3005      node (and for all of the local ..._DECL nodes which are its children)
3006      so that they all point to themselves.  */
3007
3008   set_decl_origin_self (fndecl);
3009
3010   /* Compile this function all the way down to assembly code.  */
3011   rest_of_compilation (fndecl);
3012
3013   current_function_decl = 0;
3014 }