Make TRUE/FALSE edge calculation available without the outgoing edge class.
authorAndrew MacLeod <amacleod@redhat.com>
Mon, 26 Apr 2021 22:14:15 +0000 (18:14 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Fri, 7 May 2021 19:00:21 +0000 (15:00 -0400)
Rename class to gimple_outoging_edge and provide a non-class routine for
the outgoing edge of a gcond.

* gimple-range-edge.h (gimple_outgoing_range): Rename from
outgoing_range.
(gcond_edge_range): Export prototype.
* gimple-range-edge.cc (gcond_edge_range): New.
(gimple_outgoing_range::edge_range_p): Use gcond_edge_range.
* gimple-range-gori.h (gori_compute): Use gimple_outgoing_range.

gcc/gimple-range-edge.cc
gcc/gimple-range-edge.h
gcc/gimple-range-gori.h

index 4d4cb97..d11153e 100644 (file)
@@ -52,12 +52,26 @@ gimple_outgoing_range_stmt_p (basic_block bb)
 }
 
 
-outgoing_range::outgoing_range ()
+// Return a TRUE or FALSE range representing the edge value of a GCOND.
+
+void
+gcond_edge_range (irange &r, edge e)
+{
+  gcc_checking_assert (e->flags & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE));
+  if (e->flags & EDGE_TRUE_VALUE)
+    r = int_range<2> (boolean_true_node, boolean_true_node);
+  else
+    r = int_range<2> (boolean_false_node, boolean_false_node);
+}
+
+
+gimple_outgoing_range::gimple_outgoing_range ()
 {
   m_edge_table = NULL;
 }
 
-outgoing_range::~outgoing_range ()
+
+gimple_outgoing_range::~gimple_outgoing_range ()
 {
   if (m_edge_table)
     delete m_edge_table;
@@ -68,7 +82,7 @@ outgoing_range::~outgoing_range ()
 // Use a cached value if it exists, or calculate it if not.
 
 bool
-outgoing_range::get_edge_range (irange &r, gimple *s, edge e)
+gimple_outgoing_range::get_edge_range (irange &r, gimple *s, edge e)
 {
   gcc_checking_assert (is_a<gswitch *> (s));
   gswitch *sw = as_a<gswitch *> (s);
@@ -100,7 +114,7 @@ outgoing_range::get_edge_range (irange &r, gimple *s, edge e)
 // Calculate all switch edges from SW and cache them in the hash table.
 
 void
-outgoing_range::calc_switch_ranges (gswitch *sw)
+gimple_outgoing_range::calc_switch_ranges (gswitch *sw)
 {
   bool existed;
   unsigned x, lim;
@@ -165,7 +179,7 @@ outgoing_range::calc_switch_ranges (gswitch *sw)
 // return NULL
 
 gimple *
-outgoing_range::edge_range_p (irange &r, edge e)
+gimple_outgoing_range::edge_range_p (irange &r, edge e)
 {
   // Determine if there is an outgoing edge.
   gimple *s = gimple_outgoing_range_stmt_p (e->src);
@@ -174,12 +188,7 @@ outgoing_range::edge_range_p (irange &r, edge e)
 
   if (is_a<gcond *> (s))
     {
-      if (e->flags & EDGE_TRUE_VALUE)
-       r = int_range<2> (boolean_true_node, boolean_true_node);
-      else if (e->flags & EDGE_FALSE_VALUE)
-       r = int_range<2> (boolean_false_node, boolean_false_node);
-      else
-       gcc_unreachable ();
+      gcond_edge_range (r, e);
       return s;
     }
 
index 8970c9e..87b4124 100644 (file)
@@ -35,11 +35,11 @@ along with GCC; see the file COPYING3.  If not see
 // The return value is NULL for no range, or the branch statement which the
 // edge gets the range from, along with the range.
 
-class outgoing_range
+class gimple_outgoing_range
 {
 public:
-  outgoing_range ();
-  ~outgoing_range ();
+  gimple_outgoing_range ();
+  ~gimple_outgoing_range ();
   gimple *edge_range_p (irange &r, edge e);
 private:
   void calc_switch_ranges (gswitch *sw);
@@ -47,9 +47,11 @@ private:
 
   hash_map<edge, irange *> *m_edge_table;
   irange_allocator m_range_allocator;
-}; 
+};
 
-// If there is a range control statment at the end of block BB, return it.
+// If there is a range control statement at the end of block BB, return it.
 gimple *gimple_outgoing_range_stmt_p (basic_block bb);
+// Return the range on edge E if it is from a GCOND.  Either TRUE or FALSE.
+void gcond_edge_range (irange &r, edge e);
 
 #endif  // GIMPLE_RANGE_EDGE_H
index 48c746d..7bb18a9 100644 (file)
@@ -108,7 +108,7 @@ private:
                                            const irange &lhs, tree name);
 
   class gori_map *m_gori_map;
-  outgoing_range outgoing;     // Edge values for COND_EXPR & SWITCH_EXPR.
+  gimple_outgoing_range outgoing;      // Edge values for COND_EXPR & SWITCH_EXPR.
 };