OSDN Git Service

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