OSDN Git Service

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