home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / integrate.c < prev    next >
C/C++ Source or Header  |  1995-12-29  |  104KB  |  3,151 lines

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