]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Move from grange c++ interface to gimple_range accessor interface remove...
authorAndrew Macleod <amacleod@gcc.gnu.org>
Thu, 5 Sep 2019 13:46:47 +0000 (13:46 +0000)
committerAndrew Macleod <amacleod@gcc.gnu.org>
Thu, 5 Sep 2019 13:46:47 +0000 (13:46 +0000)
Move from grange c++ interface to gimple_range accessor interface
remove grange_adjust classes and replace with a simple function for now

From-SVN: r275410

gcc/grange.cc
gcc/grange.h
gcc/range-op.cc
gcc/ssa-range-gori.cc
gcc/ssa-range-gori.h
gcc/ssa-range.cc
gcc/ssa-range.h
gcc/tree-ssa-threadbackward.c

index b7fe2dec6c1d229c0595377708d41905b1d01307..32d83c5ea599697bd70fb448e8586358e4c095ff 100644 (file)
@@ -48,8 +48,54 @@ along with GCC; see the file COPYING3.  If not see
 #include "grange.h"
 #include "ssa-range.h"
 
+// This function looks for situations when walking the use/def chains
+// may provide additonal contextual range information not exposed on
+// this statement.  Like knowing the IMAGPART return value from a
+// builtin function is a boolean result.
+
+void
+gimple_range_adjustment (const grange *s, irange &res)
+{
+  switch (gimple_expr_code (s))
+    {
+    case IMAGPART_EXPR:
+      {
+       irange r;
+       tree name;
+       tree type = TREE_TYPE (gimple_assign_lhs (s));
+
+       name = TREE_OPERAND (gimple_assign_rhs1 (s), 0);
+       if (TREE_CODE (name) == SSA_NAME)
+         {
+           gimple *def_stmt = SSA_NAME_DEF_STMT (name);
+           if (def_stmt && is_gimple_call (def_stmt)
+               && gimple_call_internal_p (def_stmt))
+             {
+               switch (gimple_call_internal_fn (def_stmt))
+                 {
+                 case IFN_ADD_OVERFLOW:
+                 case IFN_SUB_OVERFLOW:
+                 case IFN_MUL_OVERFLOW:
+                 case IFN_ATOMIC_COMPARE_EXCHANGE:
+                   r.set_varying (boolean_type_node);
+                   range_cast (r, type);
+                   res.intersect (r);
+                 default:
+                   break;
+                 }
+             }
+         }
+       break;
+      }
+
+    default:
+      break;
+    }
+}
+
+
 // This file implements the gimple range statement and associated data.
-// the grange_op statement kind provides access to the range-op fold machinery
+// the grange statement kind provides access to the range-op fold machinery
 // as well as to a set of range adjustemnts which are gimple IL aware.
 //
 // This allows a statement to make adjustments to operands
@@ -171,188 +217,32 @@ gimple_outgoing_edge_range_p (irange &r, edge e)
 
 
 // ------------------------------------------------------------------------
-
-// This is the class which is used to implement range adjustments in GIMPLE.
-// It follows the same model as range_ops, where you can adjust the LHS, OP1,
-// or OP2, and self registers into the lookup table.
-
-class grange_adjust
-{
-public:
-  grange_adjust (enum tree_code c);
-  virtual bool lhs_adjust (irange &r, const gimple *s) const;
-  virtual bool op1_adjust (irange &r, const gimple *s) const;
-  virtual bool op2_adjust (irange &r, const gimple *s) const;
-protected:
-  enum tree_code code;
-};
-
-
-// This class implements a table of range adjustments that can be done for 
-// each tree code.  
-
-class gimple_range_table
-{
-public:
-  inline grange_adjust* operator[] (enum tree_code code);
-  void register_operator (enum tree_code code, grange_adjust *);
-private:
-  grange_adjust *m_range_tree[MAX_TREE_CODES];
-} grange_table;
-
-
-// Return the adjustment class pointer for tree_code CODE, or NULL if none.
-
-grange_adjust *
-gimple_range_table::operator[] (enum tree_code code)
-{
-  gcc_assert (code > 0 && code < MAX_TREE_CODES);
-  return m_range_tree[code];
-}
-
-// Called by the adjustment class constructor to register the operator
-// in the table.
-
-void
-gimple_range_table::register_operator (enum tree_code code, grange_adjust *op)
-{
-  gcc_checking_assert (m_range_tree[code] == NULL && op != NULL);
-  m_range_tree[code] = op;
-}
-
-// External entry point to return the handler for a given tree_code hiding 
-// the existance of the table.    This is required for the is_a helper
-// templates.
-
-grange_adjust *
-gimple_range_adjust_handler (enum tree_code c)
-{
-  return grange_table[c];
-}
-
-// --------------------------------------------------------------------------
-
-// Construct class grange_adjust, and register it in the table.
-
-grange_adjust::grange_adjust (enum tree_code c)
-{
-  code = c;
-  grange_table.register_operator (c, this);
-}
-
-// Return any adjustments to the range of the lhs
-
-bool
-grange_adjust::lhs_adjust (irange &r ATTRIBUTE_UNUSED,
-                          const gimple *s ATTRIBUTE_UNUSED) const
-{
-  return false;
-}
-
-// Return any adjustments to the range of op1 when querying it.
-
-bool
-grange_adjust::op1_adjust (irange &r ATTRIBUTE_UNUSED,
-                          const gimple *s ATTRIBUTE_UNUSED) const
-{
-  return false;
-}
-
-// Return any adjustments to the range of op2 when querying it.
-
-bool
-grange_adjust::op2_adjust (irange &r ATTRIBUTE_UNUSED,
-                          const gimple *s ATTRIBUTE_UNUSED) const
-{
-  return false;
-}
-
-
-// -------------------------------------------------------------------------
-
-// WHEN a certain class of builtin functions are called which return a 
-// COMPLEX_INT, the IMAGPART_EXPR is known to be either true or false.
-// ie
-//    a_5 = .ADD_OVERFLOW (blah)
-//    c_6 = IMAGPART_EXPR (a_5)
-// c_6 is actually a boolean indicating if an overflow happened.
-
-class imagpart : public grange_adjust
-{
-public:
-  imagpart () : grange_adjust (IMAGPART_EXPR) { }
-  virtual bool lhs_adjust (irange &r, const gimple *s) const;
-} imagpart_adjust;
-
-
-// If the operand of the IMAGPART_EXPR is a builtin function which is known
-// to return a boolean result, adjust the LHS ot be a 0 or 1.
-
-bool
-imagpart::lhs_adjust (irange &r, const gimple *s) const
-{
-  tree name;
-  tree type = TREE_TYPE (gimple_assign_lhs (s));
-
-  name = TREE_OPERAND (gimple_assign_rhs1 (s), 0);
-  if (TREE_CODE (name) == SSA_NAME)
-    {
-      gimple *def_stmt = SSA_NAME_DEF_STMT (name);
-      if (def_stmt && is_gimple_call (def_stmt)
-         && gimple_call_internal_p (def_stmt))
-       {
-         switch (gimple_call_internal_fn (def_stmt))
-           {
-           case IFN_ADD_OVERFLOW:
-           case IFN_SUB_OVERFLOW:
-           case IFN_MUL_OVERFLOW:
-           case IFN_ATOMIC_COMPARE_EXCHANGE:
-             r.set_varying (boolean_type_node);
-             range_cast (r, type);
-             return true;
-           default:
-             r.set_varying (type);
-             return true;
-           }
-       }
-    }
-  return false;
-}
-
-
-// ------------------------------------------------------------------------
-// grange_op statement kind implementation. 
+// grange statement kind implementation. 
 
 // Return the grange_adjust pointer for this statement, if there is one..
 
-inline grange_adjust *
-grange_op::grange_adjust_handler () const
-{
-  return gimple_range_adjust_handler (gimple_expr_code (this));
-}
-
 // Return the range_operator pointer for this statement.
 
 inline range_operator *
-grange_op::handler () const
+gimple_range_handler (const grange *s)
 {
-  return range_op_handler (gimple_expr_code (this), gimple_expr_type (this));
+  return range_op_handler (gimple_expr_code (s), gimple_expr_type (s));
 }
 
 // Return the first operand of this statement if it is a valid operand 
 // supported by ranges, otherwise return NULL_TREE. 
 
 tree
-grange_op::operand1 () const
+gimple_range_operand1 (const grange *s)
 {
-  switch (gimple_code (this))
+  switch (gimple_code (s))
     {
       case GIMPLE_COND:
-        return gimple_cond_lhs (this);
+        return gimple_cond_lhs (s);
       case GIMPLE_ASSIGN:
         {
-         tree expr = gimple_assign_rhs1 (this);
-         if (gimple_assign_rhs_code (this) == ADDR_EXPR)
+         tree expr = gimple_assign_rhs1 (s);
+         if (gimple_assign_rhs_code (s) == ADDR_EXPR)
            {
              // If the base address is an SSA_NAME, we return it here.
              // This allows processing of the range of that name, while the
@@ -380,17 +270,18 @@ grange_op::operand1 () const
 // result in RES.  Return false if the operation fails.
 
 bool
-grange_op::fold (irange &res, const irange &orig_r1) const
+gimple_range_fold (const grange *s, irange &res, const irange &orig_r1)
 {
+  tree lhs = gimple_range_lhs (s);;
   irange r1, r2;
   r1 = orig_r1;
   // Single ssa operations require the LHS type as the second range.
-  if (lhs ())
-    r2.set_varying (TREE_TYPE (lhs ()));
+  if (lhs)
+    r2.set_varying (TREE_TYPE (lhs));
   else
     r2.set_undefined ();
 
-  return fold (res, r1, r2);
+  return gimple_range_fold (s, res, r1, r2);
 }
 
 
@@ -398,31 +289,15 @@ grange_op::fold (irange &res, const irange &orig_r1) const
 // returning the result in RES.  Return false if the operation fails.
 
 bool
-grange_op::fold (irange &res, const irange &r1, const irange &r2) const
+gimple_range_fold (const grange *s, irange &res, const irange &r1,
+                  const irange &r2)
 {
   irange adj_range;
-  bool adj = false;
-  bool hand = false;
 
-  if (grange_adjust_handler ())
-    adj = grange_adjust_handler()->lhs_adjust (adj_range, this);
-  if (handler ())
-    {
-      hand = true;
-      res = handler()->fold_range (gimple_expr_type (this), r1, r2);
-    }
-
-  // Handle common case first where res was set by handler
-  // This handles whatever handler() would ahve returned.
-  if (!adj)
-    return hand;
-
-  // Now we know there was an adjustment, so make it.
-  if (!hand)
-    res =  adj_range;
-  else
-    res.intersect (adj_range);
+  res = gimple_range_handler (s)->fold_range (gimple_expr_type (s), r1, r2);
 
+  // If there are any gimple lookups, do those now.
+  gimple_range_adjustment (s, res);
   return true;
 }
 
@@ -432,13 +307,13 @@ grange_op::fold (irange &res, const irange &r1, const irange &r2) const
 // if nothing can be determined.
 
 bool
-grange_op::calc_op1_irange (irange &r, const irange &lhs_range) const
+gimple_range_calc_op1 (const grange *s, irange &r, const irange &lhs_range)
 {  
   irange type_range;
-  gcc_checking_assert (gimple_num_ops (this) < 3);
+  gcc_checking_assert (gimple_num_ops (s) < 3);
   // An empty range is viral, so return an empty range.
   
-  tree type = TREE_TYPE (operand1 ());
+  tree type = TREE_TYPE (gimple_range_operand1 (s));
   if (lhs_range.undefined_p ())
     {
       r.set_undefined ();
@@ -447,7 +322,7 @@ grange_op::calc_op1_irange (irange &r, const irange &lhs_range) const
   // Unary operations require the type of the first operand in the second range
   // position.
   type_range.set_varying (type);
-  return handler ()->op1_range (r, type, lhs_range, type_range);
+  return gimple_range_handler (s)->op1_range (r, type, lhs_range, type_range);
 }
 
 
@@ -456,21 +331,21 @@ grange_op::calc_op1_irange (irange &r, const irange &lhs_range) const
 // operand has the range OP2_RANGE.  Return false if nothing can be determined.
 
 bool
-grange_op::calc_op1_irange (irange &r, const irange &lhs_range,
-                           const irange &op2_range) const
+gimple_range_calc_op1 (const grange *s, irange &r, const irange &lhs_range,
+                      const irange &op2_range)
 {  
   // Unary operation are allowed to pass a range in for second operand
   // as there are often additional restrictions beyond the type which can
   // be imposed.  See operator_cast::op1_irange.()
   
-  tree type = TREE_TYPE (operand1 ());
+  tree type = TREE_TYPE (gimple_range_operand1 (s));
   // An empty range is viral, so return an empty range.
   if (op2_range.undefined_p () || lhs_range.undefined_p ())
     {
       r.set_undefined ();
       return true;
     }
-  return handler ()->op1_range (r, type, lhs_range, op2_range);
+  return gimple_range_handler (s)->op1_range (r, type, lhs_range, op2_range);
 }
 
 
@@ -479,15 +354,15 @@ grange_op::calc_op1_irange (irange &r, const irange &lhs_range,
 // operand has the range OP1_RANGE.  Return false if nothing can be determined.
 
 bool
-grange_op::calc_op2_irange (irange &r, const irange &lhs_range,
-                           const irange &op1_range) const
+gimple_range_calc_op2 (const grange *s, irange &r, const irange &lhs_range,
+                      const irange &op1_range)
 {  
-  tree type = TREE_TYPE (operand2 ());
+  tree type = TREE_TYPE (gimple_range_operand2 (s));
   // An empty range is viral, so return an empty range.
   if (op1_range.undefined_p () || lhs_range.undefined_p ())
     {
       r.set_undefined ();
       return true;
     }
-  return handler ()->op2_range (r, type, lhs_range, op1_range);
+  return gimple_range_handler (s)->op2_range (r, type, lhs_range, op1_range);
 }
index 973e5a243d6194fdf20db5ae3aa2308b3902f376..0f3d43514e3ac091fb709b1f11cdde0d1a469b95 100644 (file)
@@ -24,34 +24,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "range.h"
 #include "range-op.h"
 
-extern gimple_stmt_iterator gsi_outgoing_range_stmt (basic_block bb);
-extern gimple *gimple_outgoing_range_stmt_p (basic_block bb);
-extern gimple *gimple_outgoing_edge_range_p (irange &r, edge e);
-
-static inline tree
-valid_range_ssa_p (tree exp)
-{
-  if (exp && TREE_CODE (exp) == SSA_NAME && irange::supports_ssa_p (exp))
-    return exp;
-  return NULL_TREE;
-}
-
-static inline irange
-ssa_name_range (tree name)
-{
-  gcc_checking_assert (irange::supports_ssa_p (name));
-  tree type = TREE_TYPE (name);
-  if (!POINTER_TYPE_P (type) && SSA_NAME_RANGE_INFO (name))
-    {
-      // Return a range from an SSA_NAME's available range.  
-      wide_int min, max;
-      enum value_range_kind kind = get_range_info (name, &min, &max);
-      return irange (kind, type, min, max);
-    }
- // Otherwise return range for the type.
- return irange (type);
-}
-
 // Gimple statement which supports range_op operations.
 // This can map to gimple assign or cond statements, so quick access to the
 // operands is provided so the user does not need to know which it is.
@@ -61,75 +33,32 @@ ssa_name_range (tree name)
 // usage is typical gimple statement style:
 // foo (gimple *s)
 // {
-//   grange_op gr = s;
+//   grange gr = s;
 //   if (!gr)
 //     return false;  // NULL means this stmt cannot generate ranges.
 //   < ...decide on some ranges... >
 //   /* And call the range fold routine for this statement.  */
-//   return gr->fold (res_range, op1_range, op2_range);
+//   return gimple_range_fold (gr, res_range, op1_range, op2_range);
 
 class GTY((tag("GCC_SSA_RANGE_OPERATOR")))
-  grange_op: public gimple
+  grange: public gimple
 {
-public:
   // Adds no new fields, adds invariant 
   // stmt->code == GIMPLE_ASSIGN || stmt->code == GIMPLE_COND
   // and there is a range_operator handler for gimple_expr_code().
-  tree lhs () const;
-  tree operand1 () const;
-  tree operand2 () const;
-
-  bool fold (irange &res, const irange &r1) const;
-  bool calc_op1_irange (irange &r, const irange &lhs_range) const;
-
-  bool fold (irange &res, const irange &r1, const irange &r2) const;
-  bool calc_op1_irange (irange &r, const irange &lhs_range,
-                  const irange &op2_range) const;
-  bool calc_op2_irange (irange &r, const irange &lhs_range,
-                  const irange &op1_range) const;
-private:
-  // Range-op IL agnostic range calculations handler.
-  class range_operator *handler() const;
-  // IL contextual range information adjustments handler.
-  class grange_adjust *grange_adjust_handler () const;
 };
 
-// Return the LHS of this statement. If there isn't a LHS return NULL_TREE.
-
-inline tree
-grange_op::lhs () const
-{
-  if (gimple_code (this) == GIMPLE_ASSIGN)
-    return gimple_assign_lhs (this);
-  return NULL_TREE;
-}
-
-// Return the second operand of this statement, otherwise return NULL_TREE.
-
-inline tree
-grange_op::operand2 () const
-{
-  if (gimple_code (this) == GIMPLE_COND)
-    return gimple_cond_rhs (this);
-
-  // At this point it must be an assignemnt statement.
-  if (gimple_num_ops (this) >= 3)
-    return gimple_assign_rhs2 (this);
-  return NULL_TREE;
-}
-
 template <>
 template <>
 inline bool
-is_a_helper <const grange_op *>::test (const gimple *gs)
+is_a_helper <const grange *>::test (const gimple *gs)
 { 
-  extern grange_adjust *gimple_range_adjust_handler (enum tree_code c);
   // Supported statement kind and there is a handler for the expression code.
   if (dyn_cast<const gassign *> (gs) || dyn_cast<const gcond *>(gs))
     {
       enum tree_code c = gimple_expr_code (gs);
       tree expr_type = gimple_expr_type (gs);
-      return range_op_handler (c, expr_type) || gimple_range_adjust_handler (c);
+      return range_op_handler (c, expr_type);
     }
   return false;
 }
@@ -137,18 +66,88 @@ is_a_helper <const grange_op *>::test (const gimple *gs)
 template <>
 template <>
 inline bool
-is_a_helper <grange_op *>::test (gimple *gs)
+is_a_helper <grange *>::test (gimple *gs)
 { 
-  extern grange_adjust *gimple_range_adjust_handler (enum tree_code c);
   // Supported statement kind and there is a handler for the expression code.
   // Supported statement kind and there is a handler for the expression code.
   if (dyn_cast<gassign *> (gs) || dyn_cast<gcond *>(gs))
     {
       enum tree_code c = gimple_expr_code (gs);
       tree expr_type = gimple_expr_type (gs);
-      return range_op_handler (c, expr_type) || gimple_range_adjust_handler (c);
+      return range_op_handler (c, expr_type);
     }
   return false;
 }
 
+// Return the LHS of this statement. If there isn't a LHS return NULL_TREE.
+
+static inline tree
+gimple_range_lhs (const grange *s)
+{
+  if (gimple_code (s) == GIMPLE_ASSIGN)
+    return gimple_assign_lhs (s);
+  return NULL_TREE;
+}
+
+
+// Return the second operand of this statement, otherwise return NULL_TREE.
+
+static inline tree
+gimple_range_operand2 (const grange *s)
+{
+  if (gimple_code (s) == GIMPLE_COND)
+    return gimple_cond_rhs (s);
+
+  // At this point it must be an assignemnt statement.
+  if (gimple_num_ops (s) >= 3)
+    return gimple_assign_rhs2 (s);
+  return NULL_TREE;
+}
+
+
+
+extern tree gimple_range_operand1 (const grange *s);
+extern bool gimple_range_fold (const grange *s, irange &res,
+                              const irange &r1);
+extern bool gimple_range_fold (const grange *s, irange &res,
+                              const irange &r1, const irange &r2);
+extern bool gimple_range_calc_op1 (const grange *s, irange &r,
+                                  const irange &lhs_range);
+extern bool gimple_range_calc_op1 (const grange *s, irange &r,
+                                  const irange &lhs_range,
+                                  const irange &op2_range);
+extern bool gimple_range_calc_op2 (const grange *s, irange &r,
+                                  const irange &lhs_range,
+                                  const irange &op1_range);
+
+
+extern gimple_stmt_iterator gsi_outgoing_range_stmt (basic_block bb);
+extern gimple *gimple_outgoing_range_stmt_p (basic_block bb);
+extern gimple *gimple_outgoing_edge_range_p (irange &r, edge e);
+
+static inline tree
+valid_range_ssa_p (tree exp)
+{
+  if (exp && TREE_CODE (exp) == SSA_NAME && irange::supports_ssa_p (exp))
+    return exp;
+  return NULL_TREE;
+}
+
+static inline irange
+ssa_name_range (tree name)
+{
+  gcc_checking_assert (irange::supports_ssa_p (name));
+  tree type = TREE_TYPE (name);
+  if (!POINTER_TYPE_P (type) && SSA_NAME_RANGE_INFO (name))
+    {
+      // Return a range from an SSA_NAME's available range.  
+      wide_int min, max;
+      enum value_range_kind kind = get_range_info (name, &min, &max);
+      return irange (kind, type, min, max);
+    }
+ // Otherwise return range for the type.
+ return irange (type);
+}
+
+
 #endif // GCC_GRANGE_H
index 6b27fb242a9e0ccefb149a10ea1f28d008d6ec12..fc59802fef8e0c20b7d9a448e09dc42ba2c3bef7 100644 (file)
@@ -2849,6 +2849,9 @@ integral_table::integral_table ()
   set (ABSU_EXPR, op_absu);
   set (NEGATE_EXPR, op_negate);
   set (ADDR_EXPR, op_addr);
+
+  // Add entries to the table so gimple enhacements can be triggered.
+  set (IMAGPART_EXPR, op_identity);
 }
 
 
index a11241702db772eb22ba3bcbd153fe9a0bff9b6b..fd4035edd8a78100157e6a02285d68d816eccffb 100644 (file)
@@ -168,11 +168,11 @@ range_def_chain::get_def_chain (tree name)
     return NULL;
 
   gimple *s = SSA_NAME_DEF_STMT (name);
-  if (is_a<grange_op *> (s))
+  if (is_a<grange *> (s))
     { 
-      grange_op *stmt = as_a<grange_op *> (s);
-      ssa1 = valid_range_ssa_p (stmt->operand1 ());
-      ssa2 = valid_range_ssa_p (stmt->operand2 ());
+      grange *stmt = as_a<grange *> (s);
+      ssa1 = valid_range_ssa_p (gimple_range_operand1 (stmt));
+      ssa2 = valid_range_ssa_p (gimple_range_operand2 (stmt));
       ssa3 = NULL_TREE;
     }
   else if (is_a<gassign *> (s) && gimple_assign_rhs_code (s) == COND_EXPR)
@@ -495,13 +495,13 @@ get_tree_range (tree expr, tree name, irange *range_of_name)
 // Return the result in R. Return false if no range can be calculated.
 
 static bool
-compute_operand_range_on_stmt (irange &r, grange_op *s, const irange &lhs,
+compute_operand_range_on_stmt (irange &r, grange *s, const irange &lhs,
                               tree name, irange *name_range)
 {
   irange op1_range, op2_range;
 
-  tree op1 = s->operand1 ();
-  tree op2 = s->operand2 ();
+  tree op1 = gimple_range_operand1 (s);
+  tree op2 = gimple_range_operand2 (s);
 
   // Operand 1 is the name being looked for, evaluate it.
   if (op1 == name)
@@ -512,11 +512,11 @@ compute_operand_range_on_stmt (irange &r, grange_op *s, const irange &lhs,
          // of operand1, but if it can be reduced further, the results will
          // be better.  Start with what we know of the range of OP1.
          op1_range = get_tree_range (op1, name, name_range);
-         return s->calc_op1_irange (r, lhs, op1_range);
+         return gimple_range_calc_op1 (s, r, lhs, op1_range);
        }
       // If we need the second operand, get a value and evaluate.
       op2_range = get_tree_range (op2, name, name_range);
-      if (s->calc_op1_irange (r, lhs, op2_range))
+      if (gimple_range_calc_op1 (s, r, lhs, op2_range))
        {
          // If op1 also has a range, intersect the 2 ranges.
          if (name_range)
@@ -529,7 +529,7 @@ compute_operand_range_on_stmt (irange &r, grange_op *s, const irange &lhs,
   if (op2 == name)
     {
       op1_range = get_tree_range (op1, name, name_range);
-      if (s->calc_op2_irange (r, lhs, op1_range))
+      if (gimple_range_calc_op2 (s, r, lhs, op1_range))
        {
          // If op2 also has a range, intersect the 2 ranges.
          if (name_range)
@@ -550,8 +550,8 @@ bool
 compute_operand_range_on_stmt (irange &r, gimple *s, const irange &lhs,
                               tree name, irange *name_range)
 {
-  if (is_a<grange_op *> (s))
-    return compute_operand_range_on_stmt (r, as_a<grange_op *> (s),  lhs, name,
+  if (is_a<grange *> (s))
+    return compute_operand_range_on_stmt (r, as_a<grange *> (s),  lhs, name,
                                          name_range);
   if (is_a<gswitch *> (s))
     {
@@ -589,8 +589,8 @@ bool
 gori_compute::compute_operand_range (irange &r, gimple *s, const irange &lhs,
                                     tree name, irange *name_range)
 {
-  if (is_a<grange_op *> (s))
-    return compute_operand_range_op (r, as_a<grange_op *> (s), lhs, name,
+  if (is_a<grange *> (s))
+    return compute_operand_range_op (r, as_a<grange *> (s), lhs, name,
                                     name_range);
   if (is_a<gswitch *> (s))
     return compute_operand_range_switch (r, as_a<gswitch *> (s), lhs, name,
@@ -662,7 +662,7 @@ is_gimple_logical_p (const gimple *gs)
 // If present, NAME_RANGE is any known range for NAME coming into S.
 
 bool
-gori_compute::compute_operand_range_op (irange &r, grange_op *stmt, 
+gori_compute::compute_operand_range_op (irange &r, grange *stmt, 
                                        const irange &lhs, tree name,
                                        irange *name_range)
 {
@@ -676,8 +676,8 @@ gori_compute::compute_operand_range_op (irange &r, grange_op *stmt,
       return true;
     }
 
-  op1 = valid_range_ssa_p (stmt->operand1 ());
-  op2 = valid_range_ssa_p (stmt->operand2 ());
+  op1 = valid_range_ssa_p (gimple_range_operand1 (stmt));
+  op2 = valid_range_ssa_p (gimple_range_operand2 (stmt));
 
   // The base ranger handles NAME on this statement.
   if (op1 == name || op2 == name)
@@ -817,7 +817,7 @@ gori_compute::logical_combine (irange &r, enum tree_code code,
 // If present, NAME_RANGE is any known range for NAME coming into S.
 
 bool
-gori_compute::compute_logical_operands (irange &r, grange_op *s, 
+gori_compute::compute_logical_operands (irange &r, grange *s, 
                                        const irange &lhs, tree name,
                                        irange *name_range)
 {
@@ -832,8 +832,8 @@ gori_compute::compute_logical_operands (irange &r, grange_op *s,
 
   // Reaching this point means NAME is not in this stmt, but one of the
   // names in it ought to be derived from it.  */
-  op1 = s->operand1 ();
-  op2 = s->operand2 ();
+  op1 = gimple_range_operand1 (s);
+  op2 = gimple_range_operand2 (s);
   gcc_checking_assert (op1 != name && op2 != name);
 
   op1_in_chain = valid_range_ssa_p (op1) && in_chain_p (name, op1);
@@ -902,13 +902,13 @@ gori_compute::compute_logical_operands (irange &r, grange_op *s,
 // If present, NAME_RANGE is any known range for NAME coming into S.
 
 bool
-gori_compute::compute_operand1_range (irange &r, grange_op *s, 
+gori_compute::compute_operand1_range (irange &r, grange *s, 
                                      const irange &lhs, tree name, 
                                      irange *name_range)
 {
   irange op1_range, op2_range;
-  tree op1 = s->operand1 ();
-  tree op2 = s->operand2 ();
+  tree op1 = gimple_range_operand1 (s);
+  tree op2 = gimple_range_operand2 (s);
 
   // Determine a known range for operand1 ().
   op1_range = get_tree_range (op1, name, name_range);
@@ -919,13 +919,13 @@ gori_compute::compute_operand1_range (irange &r, grange_op *s,
       // we pass op1_range to the unary operation. Nomally it's a hidden
       // range_for_type parameter, but sometimes having the actual range
       // can result in better information.
-      if (!s->calc_op1_irange (r, lhs, op1_range))
+      if (!gimple_range_calc_op1 (s, r, lhs, op1_range))
        return false;
     }
   else
     {
       op2_range = get_tree_range (op2, name, name_range);
-      if (!s->calc_op1_irange (r, lhs, op2_range))
+      if (!gimple_range_calc_op1 (s, r, lhs, op2_range))
        return false;
     }
 
@@ -944,19 +944,19 @@ gori_compute::compute_operand1_range (irange &r, grange_op *s,
 // If present, NAME_RANGE is any known range for NAME coming into S.
 
 bool
-gori_compute::compute_operand2_range (irange &r, grange_op *s,
+gori_compute::compute_operand2_range (irange &r, grange *s,
                                      const irange &lhs, tree name,
                                      irange *name_range)
 {
   irange op1_range, op2_range;
-  tree op1 = s->operand1 ();
-  tree op2 = s->operand2 ();
+  tree op1 = gimple_range_operand1 (s);
+  tree op2 = gimple_range_operand2 (s);
 
   // Get a range for op1.
   op1_range = get_tree_range (op1, name, name_range);
 
   // calculate the range for op2 based on lhs and op1.
-  if (!s->calc_op2_irange (op2_range, lhs, op1_range))
+  if (!gimple_range_calc_op2 (s, op2_range, lhs, op1_range))
     return false;
 
   // Also pick up what is known about op2's range at this point
@@ -976,7 +976,7 @@ gori_compute::compute_operand2_range (irange &r, grange_op *s,
 // If present, NAME_RANGE is any known range for NAME coming into S.
 
 bool
-gori_compute::compute_operand1_and_operand2_range (irange &r, grange_op *s,
+gori_compute::compute_operand1_and_operand2_range (irange &r, grange *s,
                                                   const irange &lhs, tree name,
                                                   irange *name_range)
 {
@@ -1117,12 +1117,12 @@ gori_compute::range_from_import (irange &r, tree name, irange &import_range)
   // if (b_4 < d_6), but there is no DEF for this stmt, so it can't happen.
   // f_5 = b_4 + d_6 would have no import since there are 2 symbolics.
   
-  grange_op *s = dyn_cast<grange_op *> (SSA_NAME_DEF_STMT (name));
+  grange *s = dyn_cast<grange *> (SSA_NAME_DEF_STMT (name));
   if (!s)
     return false;
 
-  tree op1 = s->operand1 ();
-  tree op2 = s->operand2 ();
+  tree op1 = gimple_range_operand1 (s);
+  tree op2 = gimple_range_operand2 (s);
 
   // Evaluate op1
   if (valid_range_ssa_p (op1))
@@ -1138,7 +1138,7 @@ gori_compute::range_from_import (irange &r, tree name, irange &import_range)
   if (!res)
     return false;
   if (!op2)
-    return s->fold (r, r1);
+    return gimple_range_fold (s, r, r1);
 
   // Now evaluate op2.
   if (valid_range_ssa_p (op2))
@@ -1152,7 +1152,7 @@ gori_compute::range_from_import (irange &r, tree name, irange &import_range)
     r2 = get_tree_range (op2, NULL_TREE, NULL);
 
   if (res)
-    return s->fold (r, r1, r2);
+    return gimple_range_fold (s, r, r1, r2);
 
   return false;
 }
index 715d58977c554e3952673cd950fd2e47178bab23..22748567d4eb4c277bb04c1a1cedaed3a178b79c 100644 (file)
@@ -61,7 +61,7 @@ along with GCC; see the file COPYING3.  If not see
     imports as the dont really reside in the block, but rather are
     accumulators of values from incoming edges.
     
-    Def chains also only include statements which are valid grange_op's so
+    Def chains also only include statements which are valid grange's so
     a def chain will only span statements for which the range engine
     implements operations.  */
 
@@ -166,16 +166,16 @@ private:
                              tree name, irange *name_range = NULL);
   bool compute_operand_range_switch (irange &r, gswitch *s, const irange &lhs,
                                     tree name, irange *name_range);
-  bool compute_operand_range_op (irange &r, grange_op *stmt, const irange &lhs,
+  bool compute_operand_range_op (irange &r, grange *stmt, const irange &lhs,
                                 tree name, irange *name_range);
-  bool compute_operand1_range (irange &r, grange_op *s, const irange &lhs,
+  bool compute_operand1_range (irange &r, grange *s, const irange &lhs,
                               tree name, irange *name_range);
-  bool compute_operand2_range (irange &r, grange_op *s, const irange &lhs,
+  bool compute_operand2_range (irange &r, grange *s, const irange &lhs,
                               tree name, irange *name_range);
-  bool compute_operand1_and_operand2_range (irange &r, grange_op *s, 
+  bool compute_operand1_and_operand2_range (irange &r, grange *s, 
                                            const irange &lhs, tree name,
                                            irange *name_range);
-  bool compute_logical_operands (irange &r, grange_op *s, const irange &lhs,
+  bool compute_logical_operands (irange &r, grange *s, const irange &lhs,
                                 tree name, irange *name_range);
   bool logical_combine (irange &r, enum tree_code code, const irange &lhs,
                        const irange &op1_true, const irange &op1_false,
index b0e93b182c626b168b8e18bf5cb5845a9259f12f..a127384b2eab328f54e9ac21fe81cfa0396c975a 100644 (file)
@@ -53,18 +53,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "vr-values.h"
 #include "dbgcnt.h"
 
-// Initialize a ranger.
-
-stmt_ranger::stmt_ranger ()
-{
-}
-
-// Destruct a ranger.
-
-stmt_ranger::~stmt_ranger ()
-{
-}
-
 irange
 stmt_ranger::range_of_ssa_name (tree name, gimple *s ATTRIBUTE_UNUSED)
 {
@@ -134,8 +122,8 @@ stmt_ranger::range_of_stmt (irange &r, gimple *s, tree name)
   // If name is specified, make sure it a LHS of S.
   gcc_checking_assert (name ? SSA_NAME_DEF_STMT (name) == s : true);
 
-  if (is_a<grange_op *> (s))
-    res = range_of_range_op (r, as_a<grange_op *> (s));
+  if (is_a<grange *> (s))
+    res = range_of_grange (r, as_a<grange *> (s));
   else if (is_a<gphi *>(s))
     res = range_of_phi (r, as_a<gphi *> (s));
   else if (is_a<gcall *>(s))
@@ -176,8 +164,8 @@ bool
 stmt_ranger::range_of_stmt_with_range (irange &r, gimple *s, tree name,
                                       const irange &name_range)
 {
-  if (is_a<grange_op *> (s))
-    return range_of_range_op (r, as_a<grange_op *> (s), name, name_range);
+  if (is_a<grange *> (s))
+    return range_of_grange (r, as_a<grange *> (s), name, name_range);
   if (is_a<gphi *>(s))
     return range_of_phi (r, as_a<gphi *> (s), name, &name_range);
   if (is_a<gcall *>(s))
@@ -194,15 +182,15 @@ stmt_ranger::range_of_stmt_with_range (irange &r, gimple *s, tree name,
 // return false.
 
 inline bool
-stmt_ranger::range_of_range_op_core (irange &r, grange_op *s, bool valid,
+stmt_ranger::range_of_grange_core (irange &r, grange *s, bool valid,
                                     irange &range1, irange &range2)
 {
   if (valid)
     {
-      if (s->operand2 ())
-       valid = s->fold (r, range1, range2);
+      if (gimple_range_operand2 (s))
+       valid = gimple_range_fold (s, r, range1, range2);
       else
-       valid = s->fold (r, range1);
+       valid = gimple_range_fold (s, r, range1);
     }
 
   // If range_of_expr or fold() fails, return varying.
@@ -215,14 +203,14 @@ stmt_ranger::range_of_range_op_core (irange &r, grange_op *s, bool valid,
 // cannot be calculated, return false.  
 
 bool
-stmt_ranger::range_of_range_op (irange &r, grange_op *s)
+stmt_ranger::range_of_grange (irange &r, grange *s)
 {
   irange range1, range2;
   bool res = true;
   gcc_checking_assert (irange::supports_type_p (gimple_expr_type (s)));
 
-  tree op1 = s->operand1 ();
-  tree op2 = s->operand2 ();
+  tree op1 = gimple_range_operand1 (s);
+  tree op2 = gimple_range_operand2 (s);
 
   // Calculate a range for operand 1.
   res = range_of_expr (range1, op1, s);
@@ -231,7 +219,7 @@ stmt_ranger::range_of_range_op (irange &r, grange_op *s)
   if (res && op2)
     res = range_of_expr (range2, op2, s);
 
-  return range_of_range_op_core (r, s, res, range1, range2);
+  return range_of_grange_core (r, s, res, range1, range2);
 }
 
 // Calculate a range for range_op statement S and return it in R.  If any
@@ -239,15 +227,15 @@ stmt_ranger::range_of_range_op (irange &r, grange_op *s)
 // cannot be calculated, return false.  
 
 bool
-stmt_ranger::range_of_range_op (irange &r, grange_op *s, tree name,
+stmt_ranger::range_of_grange (irange &r, grange *s, tree name,
                              const irange &name_range)
 {
   irange range1, range2;
   bool res = true;
   gcc_checking_assert (irange::supports_type_p (gimple_expr_type (s)));
 
-  tree op1 = s->operand1 ();
-  tree op2 = s->operand2 ();
+  tree op1 = gimple_range_operand1 (s);
+  tree op2 = gimple_range_operand2 (s);
 
   // Calculate a range for operand 1.
   if (op1 == name)
@@ -264,7 +252,7 @@ stmt_ranger::range_of_range_op (irange &r, grange_op *s, tree name,
        res = range_of_expr (range2, op2, s);
     }
 
-  return range_of_range_op_core (r, s, res, range1, range2);
+  return range_of_grange_core (r, s, res, range1, range2);
 }
 
 // Calculate a range for range_op statement S and return it in R.  Evaluate
@@ -272,14 +260,14 @@ stmt_ranger::range_of_range_op (irange &r, grange_op *s, tree name,
 // cannot be calculated, return false.  
 
 bool
-stmt_ranger::range_of_range_op (irange &r, grange_op *s, gimple *eval_from)
+stmt_ranger::range_of_grange (irange &r, grange *s, gimple *eval_from)
 {
   irange range1, range2;
   bool res = true;
   gcc_checking_assert (irange::supports_type_p (gimple_expr_type (s)));
 
-  tree op1 = s->operand1 ();
-  tree op2 = s->operand2 ();
+  tree op1 = gimple_range_operand1 (s);
+  tree op2 = gimple_range_operand2 (s);
 
   // Calculate a range for operand 1.
   res = range_of_expr (range1, op1, eval_from);
@@ -288,7 +276,7 @@ stmt_ranger::range_of_range_op (irange &r, grange_op *s, gimple *eval_from)
   if (res && op2)
     res = range_of_expr (range2, op2, eval_from);
 
-  return range_of_range_op_core (r, s, res, range1, range2);
+  return range_of_grange_core (r, s, res, range1, range2);
 }
 
 
@@ -419,19 +407,6 @@ stmt_ranger::range_of_cond_expr  (irange &r, gassign *s, tree name,
 }
 
 
-// Initialize a CFG ranger.
-
-ssa_ranger::ssa_ranger ()
-{
-}
-
-// Destruct a ranger.
-
-ssa_ranger::~ssa_ranger ()
-{
-}
-
-
 // Calculate a range on edge E and return it in R.  Try to evaluate a range
 // for NAME on this edge.  Return FALSE if this is either not a control edge
 // or NAME is not defined by this edge.
@@ -536,14 +511,14 @@ ssa_ranger::range_on_exit (irange &r, basic_block bb, tree name)
 // calculated, return false.  
 
 bool
-ssa_ranger::range_of_range_op (irange &r, grange_op *s, edge eval_on)
+ssa_ranger::range_of_grange (irange &r, grange *s, edge eval_on)
 {
   irange range1, range2;
   bool res = true;
   gcc_checking_assert (irange::supports_type_p (gimple_expr_type (s)));
 
-  tree op1 = s->operand1 ();
-  tree op2 = s->operand2 ();
+  tree op1 = gimple_range_operand1 (s);
+  tree op2 = gimple_range_operand2 (s);
 
   // Calculate a range for operand 1.
   range_on_edge (range1, eval_on, op1);
@@ -552,7 +527,7 @@ ssa_ranger::range_of_range_op (irange &r, grange_op *s, edge eval_on)
   if (op2)
     range_on_edge (range2, eval_on, op2);
 
-  return range_of_range_op_core (r, s, res, range1, range2);
+  return range_of_grange_core (r, s, res, range1, range2);
 }
 
 bool
index 7209403fdf85d6d66ec263a330faa108c7794d51..16c1c0ed05c75a4bc1091b373068648f75241909 100644 (file)
@@ -45,8 +45,6 @@ along with GCC; see the file COPYING3.  If not see
 class stmt_ranger
 {
   public:
-  stmt_ranger ();
-  ~stmt_ranger ();
   
   bool range_of_expr (irange &r, tree expr, gimple *s = NULL);
   virtual irange range_of_ssa_name (tree name, gimple *s = NULL);
@@ -55,12 +53,12 @@ class stmt_ranger
                                         const irange &name_range);
 protected:
   // Calculate a range for a kind of gimple statement .
-  bool range_of_range_op_core (irange &r, grange_op *s, bool valid,
+  bool range_of_grange_core (irange &r, grange *s, bool valid,
                               irange &range1, irange &range2);
-  bool range_of_range_op  (irange &r, grange_op *s);
-  bool range_of_range_op  (irange &r, grange_op *s, tree name,
+  bool range_of_grange  (irange &r, grange *s);
+  bool range_of_grange  (irange &r, grange *s, tree name,
                           const irange &name_range);
-  bool range_of_range_op  (irange &r, grange_op *s, gimple *eval_from);
+  bool range_of_grange  (irange &r, grange *s, gimple *eval_from);
 
   virtual bool range_of_phi (irange &r, gphi *phi, tree name = NULL_TREE,
                             const irange *name_range = NULL,
@@ -78,8 +76,6 @@ protected:
 class ssa_ranger : public stmt_ranger
 {
   public:
-  ssa_ranger ();
-  ~ssa_ranger ();
   virtual void range_on_edge (irange &r, edge e, tree name);
   virtual void range_on_entry (irange &r, basic_block bb, tree name);
   virtual void range_on_exit (irange &r, basic_block bb, tree name);
@@ -89,7 +85,7 @@ class ssa_ranger : public stmt_ranger
   
 protected:
   bool range_of_cond_expr (irange &r, gassign* call, edge on_edge);
-  bool range_of_range_op  (irange &r, grange_op *s, edge on_edge);
+  bool range_of_grange  (irange &r, grange *s, edge on_edge);
   virtual bool range_of_phi (irange &r, gphi *phi, tree name = NULL_TREE,
                             const irange *name_range = NULL,
                             gimple *eval_from = NULL, edge on_edge = NULL);
index d4aaec36dceeb13305b17188c4052a2363b2f696..1574eb2f13217d7f0af9e112783e0671c0b78583 100644 (file)
@@ -117,26 +117,26 @@ thread_ranger::range_of_stmt_edge (irange &r, gimple *g, edge e)
       return true;
     }
 
-  grange_op *stmt = dyn_cast<grange_op *>(g);
+  grange *stmt = dyn_cast<grange *>(g);
   if (!stmt)
     return false; 
   irange range1, range2;
 
-  tree op = stmt->operand1 ();
+  tree op = gimple_range_operand1 (stmt);
   if (!valid_range_ssa_p (op) || !ssa_name_same_bb_p (op, bb) ||
       !range_of_stmt_edge (range1, SSA_NAME_DEF_STMT (op), e))
     if (!range_of_expr (range1, op))
       return false;
 
-  op = stmt->operand2 ();
+  op = gimple_range_operand2 (stmt);
   if (!op)
-    return stmt->fold (r, range1);
+    return gimple_range_fold (stmt, r, range1);
 
   if (!valid_range_ssa_p (op) || !ssa_name_same_bb_p (op, bb) ||
       !range_of_stmt_edge (range2, SSA_NAME_DEF_STMT (op), e))
     if (!range_of_expr (range2, op))
       return false;
-  return stmt->fold (r, range1, range2);
+  return gimple_range_fold (stmt, r, range1, range2);
 }
 
 // Calculate the known range for NAME on a path of basic blocks in