OSDN Git Service

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