From 2ee358081cbf39da073e9539cd5f21010f7d5a94 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Wed, 18 Jun 2014 17:07:28 -0400
Subject: [PATCH 103/244] ree.c: Use rtx_insn

gcc/
	* ree.c (struct ext_cand): Strengthen field "insn" from rtx to
	rtx_insn *.
	(combine_set_extension): Likewise for param "curr_insn".
	(transform_ifelse): Likewise for param "def_insn".
	(get_defs): Likewise for param "def_insn".  Strengthen param "dest"
	from vec<rtx> * to vec<rtx_insn *> *.
	(is_cond_copy_insn): Likewise for param "insn".
	(struct ext_state): Strengthen the four vec fields from vec<rtx>
	to vec<rtx_insn *>.
	(make_defs_and_copies_lists): Strengthen param "extend_insn" and
	local "def_insn" from rtx to rtx_insn *.
	(get_sub_rtx): Likewise for param "def_insn".
	(merge_def_and_ext): Likewise.
	(combine_reaching_defs): Likewise.
	(add_removable_extension): Likewise for param "insn".
	(find_removable_extensions): Likewise for local "insn".
	(find_and_remove_re): Likewise for locals "curr_insn" and
	"def_insn".  Strengthen locals "reinsn_del_list" and
	"reinsn_del_list" from auto_vec<rtx> to auto_vec<rtx_insn *>.
---
 gcc/ree.c | 45 +++++++++++++++++++++++----------------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/gcc/ree.c b/gcc/ree.c
index 77f1384..6ca6345 100644
--- a/gcc/ree.c
+++ b/gcc/ree.c
@@ -255,7 +255,7 @@ typedef struct ext_cand
   enum machine_mode mode;
 
   /* The instruction where it lives.  */
-  rtx insn;
+  rtx_insn *insn;
 } ext_cand;
 
 
@@ -279,7 +279,7 @@ static int max_insn_uid;
    assign it to the register.  */
 
 static bool
-combine_set_extension (ext_cand *cand, rtx curr_insn, rtx *orig_set)
+combine_set_extension (ext_cand *cand, rtx_insn *curr_insn, rtx *orig_set)
 {
   rtx orig_src = SET_SRC (*orig_set);
   rtx new_set;
@@ -383,7 +383,7 @@ combine_set_extension (ext_cand *cand, rtx curr_insn, rtx *orig_set)
    DEF_INSN is the if_then_else insn.  */
 
 static bool
-transform_ifelse (ext_cand *cand, rtx def_insn)
+transform_ifelse (ext_cand *cand, rtx_insn *def_insn)
 {
   rtx set_insn = PATTERN (def_insn);
   rtx srcreg, dstreg, srcreg2;
@@ -429,7 +429,7 @@ transform_ifelse (ext_cand *cand, rtx def_insn)
    of the definitions onto DEST.  */
 
 static struct df_link *
-get_defs (rtx insn, rtx reg, vec<rtx> *dest)
+get_defs (rtx_insn *insn, rtx reg, vec<rtx_insn *> *dest)
 {
   df_ref reg_info, *uses;
   struct df_link *ref_chain, *ref_link;
@@ -470,7 +470,7 @@ get_defs (rtx insn, rtx reg, vec<rtx> *dest)
    and store x1 and x2 in REG_1 and REG_2.  */
 
 static bool
-is_cond_copy_insn (rtx insn, rtx *reg1, rtx *reg2)
+is_cond_copy_insn (rtx_insn *insn, rtx *reg1, rtx *reg2)
 {
   rtx expr = single_set (insn);
 
@@ -517,10 +517,10 @@ typedef struct ext_state
   /* In order to avoid constant alloc/free, we keep these
      4 vectors live through the entire find_and_remove_re and just
      truncate them each time.  */
-  vec<rtx> defs_list;
-  vec<rtx> copies_list;
-  vec<rtx> modified_list;
-  vec<rtx> work_list;
+  vec<rtx_insn *> defs_list;
+  vec<rtx_insn *> copies_list;
+  vec<rtx_insn *> modified_list;
+  vec<rtx_insn *> work_list;
 
   /* For instructions that have been successfully modified, this is
      the original mode from which the insn is extending and
@@ -541,7 +541,7 @@ typedef struct ext_state
    success.  */
 
 static bool
-make_defs_and_copies_lists (rtx extend_insn, const_rtx set_pat,
+make_defs_and_copies_lists (rtx_insn *extend_insn, const_rtx set_pat,
 			    ext_state *state)
 {
   rtx src_reg = XEXP (SET_SRC (set_pat), 0);
@@ -559,7 +559,7 @@ make_defs_and_copies_lists (rtx extend_insn, const_rtx set_pat,
   /* Perform transitive closure for conditional copies.  */
   while (!state->work_list.is_empty ())
     {
-      rtx def_insn = state->work_list.pop ();
+      rtx_insn *def_insn = state->work_list.pop ();
       rtx reg1, reg2;
 
       gcc_assert (INSN_UID (def_insn) < max_insn_uid);
@@ -595,7 +595,7 @@ make_defs_and_copies_lists (rtx extend_insn, const_rtx set_pat,
    return NULL.  This is similar to single_set, except that
    single_set allows multiple SETs when all but one is dead.  */
 static rtx *
-get_sub_rtx (rtx def_insn)
+get_sub_rtx (rtx_insn *def_insn)
 {
   enum rtx_code code = GET_CODE (PATTERN (def_insn));
   rtx *sub_rtx = NULL;
@@ -633,7 +633,7 @@ get_sub_rtx (rtx def_insn)
    on the SET pattern.  */
 
 static bool
-merge_def_and_ext (ext_cand *cand, rtx def_insn, ext_state *state)
+merge_def_and_ext (ext_cand *cand, rtx_insn *def_insn, ext_state *state)
 {
   enum machine_mode ext_src_mode;
   rtx *sub_rtx;
@@ -694,7 +694,7 @@ get_extended_src_reg (rtx src)
 static bool
 combine_reaching_defs (ext_cand *cand, const_rtx set_pat, ext_state *state)
 {
-  rtx def_insn;
+  rtx_insn *def_insn;
   bool merge_successful = true;
   int i;
   int defs_ix;
@@ -743,7 +743,7 @@ combine_reaching_defs (ext_cand *cand, const_rtx set_pat, ext_state *state)
 	return false;
 
       /* There's only one reaching def.  */
-      rtx def_insn = state->defs_list[0];
+      rtx_insn *def_insn = state->defs_list[0];
 
       /* The defining statement must not have been modified either.  */
       if (state->modified[INSN_UID (def_insn)].kind != EXT_MODIFIED_NONE)
@@ -876,7 +876,7 @@ combine_reaching_defs (ext_cand *cand, const_rtx set_pat, ext_state *state)
 /* Add an extension pattern that could be eliminated.  */
 
 static void
-add_removable_extension (const_rtx expr, rtx insn,
+add_removable_extension (const_rtx expr, rtx_insn *insn,
 			 vec<ext_cand> *insn_list,
 			 unsigned *def_map)
 {
@@ -949,7 +949,8 @@ find_removable_extensions (void)
 {
   vec<ext_cand> insn_list = vNULL;
   basic_block bb;
-  rtx insn, set;
+  rtx_insn *insn;
+  rtx set;
   unsigned *def_map = XCNEWVEC (unsigned, max_insn_uid);
 
   FOR_EACH_BB_FN (bb, cfun)
@@ -976,11 +977,11 @@ static void
 find_and_remove_re (void)
 {
   ext_cand *curr_cand;
-  rtx curr_insn = NULL_RTX;
+  rtx_insn *curr_insn = NULL;
   int num_re_opportunities = 0, num_realized = 0, i;
   vec<ext_cand> reinsn_list;
-  auto_vec<rtx> reinsn_del_list;
-  auto_vec<rtx> reinsn_copy_list;
+  auto_vec<rtx_insn *> reinsn_del_list;
+  auto_vec<rtx_insn *> reinsn_copy_list;
   ext_state state;
 
   /* Construct DU chain to get all reaching definitions of each
@@ -1049,8 +1050,8 @@ find_and_remove_re (void)
      from the new destination to the old destination.  */
   for (unsigned int i = 0; i < reinsn_copy_list.length (); i += 2)
     {
-      rtx curr_insn = reinsn_copy_list[i];
-      rtx def_insn = reinsn_copy_list[i + 1];
+      rtx_insn *curr_insn = reinsn_copy_list[i];
+      rtx_insn *def_insn = reinsn_copy_list[i + 1];
 
       /* Use the mode of the destination of the defining insn
 	 for the mode of the copy.  This is necessary if the
-- 
1.8.5.3

