OSDN Git Service

PR tree-optimization/34355
[pf3gnuchains/gcc-fork.git] / gcc / tree-flow-inline.h
index 9fa5139..1074f68 100644 (file)
@@ -151,13 +151,8 @@ next_htab_element (htab_iterator *hti)
 static inline tree
 first_referenced_var (referenced_var_iterator *iter)
 {
-  struct int_tree_map *itm;
-  itm = (struct int_tree_map *) first_htab_element (&iter->hti,
-                                                    gimple_referenced_vars
-                                                   (cfun));
-  if (!itm) 
-    return NULL;
-  return itm->to;
+  return (tree) first_htab_element (&iter->hti,
+                                   gimple_referenced_vars (cfun));
 }
 
 /* Return true if we have hit the end of the referenced variables ITER is
@@ -175,11 +170,7 @@ end_referenced_vars_p (const referenced_var_iterator *iter)
 static inline tree
 next_referenced_var (referenced_var_iterator *iter)
 {
-  struct int_tree_map *itm;
-  itm = (struct int_tree_map *) next_htab_element (&iter->hti);
-  if (!itm) 
-    return NULL;
-  return itm->to;
+  return (tree) next_htab_element (&iter->hti);
 } 
 
 /* Fill up VEC with the variables in the referenced vars hashtable.  */
@@ -506,8 +497,8 @@ next_readonly_imm_use (imm_use_iterator *imm)
   use_operand_p old = imm->imm_use;
 
 #ifdef ENABLE_CHECKING
-  /* If this assertion fails, it indicates the 'next' pointer has changed 
-     since we the last bump.  This indicates that the list is being modified
+  /* If this assertion fails, it indicates the 'next' pointer has changed
+     since the last bump.  This indicates that the list is being modified
      via stmt changes, or SET_USE, or somesuch thing, and you need to be
      using the SAFE version of the iterator.  */
   gcc_assert (imm->iter_node.next == old->next);
@@ -745,21 +736,6 @@ bsi_start (basic_block bb)
   return bsi;
 }
 
-static inline const_block_stmt_iterator
-cbsi_start (const_basic_block bb)
-{
-  const_block_stmt_iterator bsi;
-  if (bb->index < NUM_FIXED_BLOCKS)
-    {
-      bsi.tsi.ptr = NULL;
-      bsi.tsi.container = NULL;
-    }
-  else
-    bsi.tsi = ctsi_start (bb_stmt_list (bb));
-  bsi.bb = bb;
-  return bsi;
-}
-
 /* Return a block statement iterator that points to the first non-label
    statement in block BB.  */
 
@@ -792,22 +768,6 @@ bsi_last (basic_block bb)
   return bsi;
 }
 
-static inline const_block_stmt_iterator
-cbsi_last (const_basic_block bb)
-{
-  const_block_stmt_iterator bsi;
-
-  if (bb->index < NUM_FIXED_BLOCKS)
-    {
-      bsi.tsi.ptr = NULL;
-      bsi.tsi.container = NULL;
-    }
-  else
-    bsi.tsi = ctsi_last (bb_stmt_list (bb));
-  bsi.bb = bb;
-  return bsi;
-}
-
 /* Return true if block statement iterator I has reached the end of
    the basic block.  */
 static inline bool
@@ -816,12 +776,6 @@ bsi_end_p (block_stmt_iterator i)
   return tsi_end_p (i.tsi);
 }
 
-static inline bool
-cbsi_end_p (const_block_stmt_iterator i)
-{
-  return ctsi_end_p (i.tsi);
-}
-
 /* Modify block statement iterator I so that it is at the next
    statement in the basic block.  */
 static inline void
@@ -830,12 +784,6 @@ bsi_next (block_stmt_iterator *i)
   tsi_next (&i->tsi);
 }
 
-static inline void
-cbsi_next (const_block_stmt_iterator *i)
-{
-  ctsi_next (&i->tsi);
-}
-
 /* Modify block statement iterator I so that it is at the previous
    statement in the basic block.  */
 static inline void
@@ -844,12 +792,6 @@ bsi_prev (block_stmt_iterator *i)
   tsi_prev (&i->tsi);
 }
 
-static inline void
-cbsi_prev (const_block_stmt_iterator *i)
-{
-  ctsi_prev (&i->tsi);
-}
-
 /* Return the statement that block statement iterator I is currently
    at.  */
 static inline tree
@@ -858,12 +800,6 @@ bsi_stmt (block_stmt_iterator i)
   return tsi_stmt (i.tsi);
 }
 
-static inline const_tree
-cbsi_stmt (const_block_stmt_iterator i)
-{
-  return ctsi_stmt (i.tsi);
-}
-
 /* Return a pointer to the statement that block statement iterator I
    is currently at.  */
 static inline tree *
@@ -1673,15 +1609,89 @@ get_subvars_for_var (tree var)
 static inline tree
 get_subvar_at (tree var, unsigned HOST_WIDE_INT offset)
 {
-  subvar_t sv;
+  subvar_t sv = get_subvars_for_var (var);
+  int low, high;
+
+  low = 0;
+  high = VEC_length (tree, sv) - 1;
+  while (low <= high)
+    {
+      int mid = (low + high) / 2;
+      tree subvar = VEC_index (tree, sv, mid);
+      if (SFT_OFFSET (subvar) == offset)
+       return subvar;
+      else if (SFT_OFFSET (subvar) < offset)
+       low = mid + 1;
+      else
+       high = mid - 1;
+    }
+
+  return NULL_TREE;
+}
+
+
+/* Return the first subvariable in SV that overlaps [offset, offset + size[.
+   NULL_TREE is returned, if there is no overlapping subvariable, else *I
+   is set to the index in the SV vector of the first overlap.  */
+
+static inline tree
+get_first_overlapping_subvar (subvar_t sv, unsigned HOST_WIDE_INT offset,
+                             unsigned HOST_WIDE_INT size, unsigned int *i)
+{
+  int low = 0;
+  int high = VEC_length (tree, sv) - 1;
+  int mid;
+  tree subvar;
 
-  for (sv = get_subvars_for_var (var); sv; sv = sv->next)
-    if (SFT_OFFSET (sv->var) == offset)
-      return sv->var;
+  if (low > high)
+    return NULL_TREE;
+
+  /* Binary search for offset.  */
+  do
+    {
+      mid = (low + high) / 2;
+      subvar = VEC_index (tree, sv, mid);
+      if (SFT_OFFSET (subvar) == offset)
+       {
+         *i = mid;
+         return subvar;
+       }
+      else if (SFT_OFFSET (subvar) < offset)
+       low = mid + 1;
+      else
+       high = mid - 1;
+    }
+  while (low <= high);
+
+  /* As we didn't find a subvar with offset, adjust to return the
+     first overlapping one.  */
+  if (SFT_OFFSET (subvar) < offset
+      && SFT_OFFSET (subvar) + SFT_SIZE (subvar) <= offset)
+    {
+      mid += 1;
+      if ((unsigned)mid >= VEC_length (tree, sv))
+       return NULL_TREE;
+      subvar = VEC_index (tree, sv, mid);
+    }
+  else if (SFT_OFFSET (subvar) > offset
+          && size <= SFT_OFFSET (subvar) - offset)
+    {
+      mid -= 1;
+      if (mid < 0)
+       return NULL_TREE;
+      subvar = VEC_index (tree, sv, mid);
+    }
+
+  if (overlap_subvar (offset, size, subvar, NULL))
+    {
+      *i = mid;
+      return subvar;
+    }
 
   return NULL_TREE;
 }
 
+
 /* Return true if V is a tree that we can have subvars for.
    Normally, this is any aggregate type.  Also complex
    types which are not gimple registers can have subvars.  */