OSDN Git Service

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