OSDN Git Service

* targhooks.c (default_unwind_emit, default_scalar_mode_supported_p):
[pf3gnuchains/gcc-fork.git] / gcc / tree-phinodes.c
index 8a8454c..712e3f9 100644 (file)
@@ -183,7 +183,7 @@ make_phi_node (tree var, int len)
     {
       free_phinode_count--;
       phi = free_phinodes[bucket];
-      free_phinodes[bucket] = TREE_CHAIN (free_phinodes[bucket]);
+      free_phinodes[bucket] = PHI_CHAIN (free_phinodes[bucket]);
 #ifdef GATHER_STATISTICS
       phi_nodes_reused++;
 #endif
@@ -202,10 +202,11 @@ make_phi_node (tree var, int len)
   memset (phi, 0, size);
   TREE_SET_CODE (phi, PHI_NODE);
   PHI_ARG_CAPACITY (phi) = len;
+  TREE_TYPE (phi) = TREE_TYPE (var);
   if (TREE_CODE (var) == SSA_NAME)
-    PHI_RESULT (phi) = var;
+    SET_PHI_RESULT (phi, var);
   else
-    PHI_RESULT (phi) = make_ssa_name (var, phi);
+    SET_PHI_RESULT (phi, make_ssa_name (var, phi));
 
   return phi;
 }
@@ -220,7 +221,7 @@ release_phi_node (tree phi)
 
   bucket = len > NUM_BUCKETS - 1 ? NUM_BUCKETS - 1 : len;
   bucket -= 2;
-  TREE_CHAIN (phi) = free_phinodes[bucket];
+  PHI_CHAIN (phi) = free_phinodes[bucket];
   free_phinodes[bucket] = phi;
   free_phinode_count++;
 }
@@ -234,12 +235,9 @@ resize_phi_node (tree *phi, int len)
   int size, old_size;
   tree new_phi;
   int i, old_len, bucket = NUM_BUCKETS - 2;
-                                                                                
-#ifdef ENABLE_CHECKING
-  if (len < PHI_ARG_CAPACITY (*phi))
-    abort ();
-#endif
-                                                                                
+
+  gcc_assert (len >= PHI_ARG_CAPACITY (*phi));
+
   /* Note that OLD_SIZE is guaranteed to be smaller than SIZE.  */
   old_size = (sizeof (struct tree_phi_node)
             + (PHI_ARG_CAPACITY (*phi) - 1) * sizeof (struct phi_arg_d));
@@ -256,7 +254,7 @@ resize_phi_node (tree *phi, int len)
     {
       free_phinode_count--;
       new_phi = free_phinodes[bucket];
-      free_phinodes[bucket] = TREE_CHAIN (free_phinodes[bucket]);
+      free_phinodes[bucket] = PHI_CHAIN (free_phinodes[bucket]);
 #ifdef GATHER_STATISTICS
       phi_nodes_reused++;
 #endif
@@ -278,7 +276,7 @@ resize_phi_node (tree *phi, int len)
                                                                                 
   for (i = old_len; i < len; i++)
     {
-      PHI_ARG_DEF (new_phi, i) = NULL_TREE;
+      SET_PHI_ARG_DEF (new_phi, i, NULL_TREE);
       PHI_ARG_EDGE (new_phi, i) = NULL;
       PHI_ARG_NONZERO (new_phi, i) = false;
     }
@@ -296,11 +294,11 @@ create_phi_node (tree var, basic_block bb)
   phi = make_phi_node (var, bb_ann (bb)->num_preds);
 
   /* This is a new phi node, so note that is has not yet been
-     rewritten. */
+     rewritten.  */
   PHI_REWRITTEN (phi) = 0;
 
   /* Add the new PHI node to the list of PHI nodes for block BB.  */
-  TREE_CHAIN (phi) = phi_nodes (bb);
+  PHI_CHAIN (phi) = phi_nodes (bb);
   bb_ann (bb)->phi_nodes = phi;
 
   /* Associate BB to the PHI node.  */
@@ -334,25 +332,30 @@ add_phi_arg (tree *phi, tree def, edge e)
         release the old PHI node.  */
       if (*phi != old_phi)
        {
+         /* Extract the basic block for the PHI from the PHI's annotation
+            rather than the edge.  This works better as the edge's
+            destination may not currently be the block with the PHI
+            node if we are in the process of threading the edge to
+            a new destination.  */
+         basic_block bb = bb_for_stmt (*phi);
+
          release_phi_node (old_phi);
 
          /* Update the list head if replacing the first listed phi.  */
-         if (phi_nodes (e->dest) == old_phi)
-           bb_ann (e->dest)->phi_nodes = *phi;
+         if (phi_nodes (bb) == old_phi)
+           bb_ann (bb)->phi_nodes = *phi;
          else
            {
              /* Traverse the list looking for the phi node to chain to.  */
              tree p;
 
-             for (p = phi_nodes (e->dest);
-                  p && TREE_CHAIN (p) != old_phi;
-                  p = TREE_CHAIN (p))
+             for (p = phi_nodes (bb);
+                  p && PHI_CHAIN (p) != old_phi;
+                  p = PHI_CHAIN (p))
                ;
 
-             if (!p)
-               abort ();
-
-             TREE_CHAIN (p) = *phi;
+             gcc_assert (p);
+             PHI_CHAIN (p) = *phi;
            }
        }
     }
@@ -365,7 +368,7 @@ add_phi_arg (tree *phi, tree def, edge e)
       SSA_NAME_OCCURS_IN_ABNORMAL_PHI (PHI_RESULT (*phi)) = 1;
     }
 
-  PHI_ARG_DEF (*phi, i) = def;
+  SET_PHI_ARG_DEF (*phi, i, def);
   PHI_ARG_EDGE (*phi, i) = e;
   PHI_ARG_NONZERO (*phi, i) = false;
   PHI_NUM_ARGS (*phi)++;
@@ -408,13 +411,13 @@ remove_phi_arg_num (tree phi, int i)
      with the element we want to delete.  */
   if (i != num_elem - 1)
     {
-      PHI_ARG_DEF (phi, i) = PHI_ARG_DEF (phi, num_elem - 1);
+      SET_PHI_ARG_DEF (phi, i, PHI_ARG_DEF (phi, num_elem - 1));
       PHI_ARG_EDGE (phi, i) = PHI_ARG_EDGE (phi, num_elem - 1);
       PHI_ARG_NONZERO (phi, i) = PHI_ARG_NONZERO (phi, num_elem - 1);
     }
 
   /* Shrink the vector and return.  */
-  PHI_ARG_DEF (phi, num_elem - 1) = NULL_TREE;
+  SET_PHI_ARG_DEF (phi, num_elem - 1, NULL_TREE);
   PHI_ARG_EDGE (phi, num_elem - 1) = NULL;
   PHI_ARG_NONZERO (phi, num_elem - 1) = false;
   PHI_NUM_ARGS (phi)--;
@@ -434,7 +437,7 @@ remove_phi_node (tree phi, tree prev, basic_block bb)
   if (prev)
     {
       /* Rewire the list if we are given a PREV pointer.  */
-      TREE_CHAIN (prev) = TREE_CHAIN (phi);
+      PHI_CHAIN (prev) = PHI_CHAIN (phi);
 
       /* If we are deleting the PHI node, then we should release the
         SSA_NAME node so that it can be reused.  */
@@ -444,7 +447,7 @@ remove_phi_node (tree phi, tree prev, basic_block bb)
   else if (phi == phi_nodes (bb))
     {
       /* Update the list head if removing the first element.  */
-      bb_ann (bb)->phi_nodes = TREE_CHAIN (phi);
+      bb_ann (bb)->phi_nodes = PHI_CHAIN (phi);
 
       /* If we are deleting the PHI node, then we should release the
         SSA_NAME node so that it can be reused.  */
@@ -456,7 +459,7 @@ remove_phi_node (tree phi, tree prev, basic_block bb)
       /* Traverse the list looking for the node to remove.  */
       tree prev, t;
       prev = NULL_TREE;
-      for (t = phi_nodes (bb); t && t != phi; t = TREE_CHAIN (t))
+      for (t = phi_nodes (bb); t && t != phi; t = PHI_CHAIN (t))
        prev = t;
       if (t)
        remove_phi_node (t, prev, bb);
@@ -481,7 +484,7 @@ remove_all_phi_nodes_for (bitmap vars)
        {
          tree var = SSA_NAME_VAR (PHI_RESULT (phi));
 
-         next = TREE_CHAIN (phi);
+         next = PHI_CHAIN (phi);
          /* Only add PHI nodes for variables not in VARS.  */
          if (!bitmap_bit_p (vars, var_ann (var)->uid))
            {
@@ -494,7 +497,7 @@ remove_all_phi_nodes_for (bitmap vars)
                new_phi_list = last_phi = phi;
              else
                {
-                 TREE_CHAIN (last_phi) = phi;
+                 PHI_CHAIN (last_phi) = phi;
                  last_phi = phi;
                }
            }
@@ -509,15 +512,14 @@ remove_all_phi_nodes_for (bitmap vars)
 
       /* Make sure the last node in the new list has no successors.  */
       if (last_phi)
-       TREE_CHAIN (last_phi) = NULL_TREE;
+       PHI_CHAIN (last_phi) = NULL_TREE;
       bb_ann (bb)->phi_nodes = new_phi_list;
 
 #if defined ENABLE_CHECKING
-      for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
+      for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
        {
          tree var = SSA_NAME_VAR (PHI_RESULT (phi));
-         if (bitmap_bit_p (vars, var_ann (var)->uid))
-           abort ();
+         gcc_assert (!bitmap_bit_p (vars, var_ann (var)->uid));
        }
 #endif
     }