public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1046] Change gori_compute to inherit from gori_map instead of having a gori-map.
@ 2021-05-25 23:29 Andrew Macleod
  0 siblings, 0 replies; only message in thread
From: Andrew Macleod @ 2021-05-25 23:29 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:28ceee1b91f48b5ab09cbd20ea6a9de6ea137af8

commit r12-1046-g28ceee1b91f48b5ab09cbd20ea6a9de6ea137af8
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Tue May 25 13:45:43 2021 -0400

    Change gori_compute to inherit from gori_map instead of having a gori-map.
    
    Move the classes to the header file and inherit instead of instantiating.
    
            * gimple-range-gori.cc (range_def_chain): Move to gimple-range-gori.h.
            (gori_map): Move to gimple-range-gori.h.
            (gori_compute::gori_compute): Adjust.
            (gori_compute::~gori_compute): Delete.
            (gori_compute::compute_operand_range_switch): Adjust.
            (gori_compute::compute_operand_range): Adjust.
            (gori_compute::compute_logical_operands): Adjust.
            (gori_compute::has_edge_range_p ): Adjust.
            (gori_compute::set_range_invariant): Delete.
            (gori_compute::dump): Adjust.
            (gori_compute::outgoing_edge_range_p): Adjust.
            * gimple-range-gori.h (class range_def_chain): Relocate here.
            (class gori_map): Relocate here.
            (class gori_compute): Inherit from gori_map, and adjust.

Diff:
---
 gcc/gimple-range-gori.cc | 76 +++++++-----------------------------------------
 gcc/gimple-range-gori.h  | 48 +++++++++++++++++++++++++++---
 2 files changed, 55 insertions(+), 69 deletions(-)

diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc
index 420282deb2d..074c025be37 100644
--- a/gcc/gimple-range-gori.cc
+++ b/gcc/gimple-range-gori.cc
@@ -91,21 +91,6 @@ is_gimple_logical_p (const gimple *gs)
     engine implements operations for.  */
 
 
-class range_def_chain
-{
-public:
-  range_def_chain ();
-  ~range_def_chain ();
-  bool has_def_chain (tree name);
-  bitmap get_def_chain (tree name);
-  bool in_chain_p (tree name, tree def);
-private:
-  vec<bitmap> m_def_chain;	// SSA_NAME : def chain components.
-  void build_def_chain (tree name, bitmap result, basic_block bb);
-  int m_logical_depth;
-};
-
-
 // Construct a range_def_chain.
 
 range_def_chain::range_def_chain ()
@@ -264,27 +249,6 @@ range_def_chain::get_def_chain (tree name)
    entire def_chain of all SSA names used in the last statement of the
    block which generate ranges.  */
 
-class gori_map : public range_def_chain
-{
-public:
-  gori_map ();
-  ~gori_map ();
-
-  bool is_export_p (tree name, basic_block bb = NULL);
-  bool def_chain_in_export_p (tree name, basic_block bb);
-  bitmap exports (basic_block bb);
-  void set_range_invariant (tree name);
-
-  void dump (FILE *f);
-  void dump (FILE *f, basic_block bb);
-private:
-  bitmap_obstack m_bitmaps;
-  vec<bitmap> m_outgoing;	// BB: Outgoing ranges calculatable on edges
-  bitmap m_maybe_variant;	// Names which might have outgoing ranges.
-  void maybe_add_gori (tree name, basic_block bb);
-  void calculate_gori (basic_block bb);
-};
-
 
 // Initialize a gori-map structure.
 
@@ -494,7 +458,6 @@ gori_compute::gori_compute ()
   // Create a boolean_type true and false range.
   m_bool_zero = int_range<2> (boolean_false_node, boolean_false_node);
   m_bool_one = int_range<2> (boolean_true_node, boolean_true_node);
-  m_gori_map = new gori_map;
   unsigned x, lim = last_basic_block_for_fn (cfun);
   // Calculate outgoing range info upfront.  This will fully populate the
   // m_maybe_variant bitmap which will help eliminate processing of names
@@ -503,17 +466,10 @@ gori_compute::gori_compute ()
     {
       basic_block bb = BASIC_BLOCK_FOR_FN (cfun, x);
       if (bb)
-	m_gori_map->exports (bb);
+	exports (bb);
     }
 }
 
-// Destruct a gori_compute_object.
-
-gori_compute::~gori_compute ()
-{
-  delete m_gori_map;
-}
-
 // Provide a default of VARYING for all incoming SSA names.
 
 void
@@ -597,7 +553,7 @@ gori_compute::compute_operand_range_switch (irange &r, gswitch *s,
     }
 
   // If op1 is in the defintion chain, pass lhs back.
-  if (gimple_range_ssa_p (op1) && m_gori_map->in_chain_p (name, op1))
+  if (gimple_range_ssa_p (op1) && in_chain_p (name, op1))
     return compute_operand_range (r, SSA_NAME_DEF_STMT (op1), lhs, name);
 
   return false;
@@ -635,8 +591,8 @@ gori_compute::compute_operand_range (irange &r, gimple *stmt,
 
   // NAME is not in this stmt, but one of the names in it ought to be
   // derived from it.
-  bool op1_in_chain = op1 && m_gori_map->in_chain_p (name, op1);
-  bool op2_in_chain = op2 && m_gori_map->in_chain_p (name, op2);
+  bool op1_in_chain = op1 && in_chain_p (name, op1);
+  bool op2_in_chain = op2 && in_chain_p (name, op2);
   if (op1_in_chain && op2_in_chain)
     return compute_operand1_and_operand2_range (r, stmt, lhs, name);
   if (op1_in_chain)
@@ -881,10 +837,8 @@ gori_compute::compute_logical_operands (irange &r, gimple *stmt,
   tree op2 = gimple_range_operand2 (stmt);
   gcc_checking_assert (op1 != name && op2 != name);
 
-  bool op1_in_chain = (gimple_range_ssa_p (op1)
-		       && m_gori_map->in_chain_p (name, op1));
-  bool op2_in_chain = (gimple_range_ssa_p (op2)
-		       && m_gori_map->in_chain_p (name, op2));
+  bool op1_in_chain = (gimple_range_ssa_p (op1) && in_chain_p (name, op1));
+  bool op2_in_chain = (gimple_range_ssa_p (op2) && in_chain_p (name, op2));
 
   // If neither operand is derived, then this stmt tells us nothing.
   if (!op1_in_chain && !op2_in_chain)
@@ -1014,18 +968,10 @@ gori_compute::has_edge_range_p (tree name, edge e)
 {
   // If no edge is specified, check if NAME is an export on any edge.
   if (!e)
-    return m_gori_map->is_export_p (name);
+    return is_export_p (name);
 
-  return (m_gori_map->is_export_p (name, e->src)
-	  || m_gori_map->def_chain_in_export_p (name, e->src));
-}
-
-// Clear the m_maybe_variant bit so ranges will not be tracked for NAME.
-
-void
-gori_compute::set_range_invariant (tree name)
-{
-  m_gori_map->set_range_invariant (name);
+  return (is_export_p (name, e->src)
+	  || def_chain_in_export_p (name, e->src));
 }
 
 // Dump what is known to GORI computes to listing file F.
@@ -1033,7 +979,7 @@ gori_compute::set_range_invariant (tree name)
 void
 gori_compute::dump (FILE *f)
 {
-  m_gori_map->dump (f);
+  gori_map::dump (f);
 }
 
 // Calculate a range on edge E and return it in R.  Try to evaluate a
@@ -1052,7 +998,7 @@ gori_compute::outgoing_edge_range_p (irange &r, edge e, tree name)
     return false;
 
   // If NAME can be calculated on the edge, use that.
-  if (m_gori_map->is_export_p (name, e->src))
+  if (is_export_p (name, e->src))
     {
       if (compute_operand_range (r, stmt, lhs, name))
 	{
diff --git a/gcc/gimple-range-gori.h b/gcc/gimple-range-gori.h
index 7bb18a9baf1..6208931a0d8 100644
--- a/gcc/gimple-range-gori.h
+++ b/gcc/gimple-range-gori.h
@@ -22,6 +22,49 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_GIMPLE_RANGE_GORI_H
 #define GCC_GIMPLE_RANGE_GORI_H
 
+// RANGE_DEF_CHAIN is used to determine which SSA names in a block can
+// have range information calculated for them, and what the
+// dependencies on each other are.
+
+class range_def_chain
+{
+public:
+  range_def_chain ();
+  ~range_def_chain ();
+  bool has_def_chain (tree name);
+  bitmap get_def_chain (tree name);
+  bool in_chain_p (tree name, tree def);
+private:
+  vec<bitmap> m_def_chain;	// SSA_NAME : def chain components.
+  void build_def_chain (tree name, bitmap result, basic_block bb);
+  int m_logical_depth;
+};
+
+// GORI_MAP is used to accumulate what SSA names in a block can
+// generate range information, and provides tools for the block ranger
+// to enable it to efficiently calculate these ranges.
+
+class gori_map : public range_def_chain
+{
+public:
+  gori_map ();
+  ~gori_map ();
+
+  bool is_export_p (tree name, basic_block bb = NULL);
+  bool def_chain_in_export_p (tree name, basic_block bb);
+  bitmap exports (basic_block bb);
+  void set_range_invariant (tree name);
+
+  void dump (FILE *f);
+  void dump (FILE *f, basic_block bb);
+private:
+  bitmap_obstack m_bitmaps;
+  vec<bitmap> m_outgoing;	// BB: Outgoing ranges calculatable on edges
+  bitmap m_maybe_variant;	// Names which might have outgoing ranges.
+  void maybe_add_gori (tree name, basic_block bb);
+  void calculate_gori (basic_block bb);
+};
+
 
 // This class is used to determine which SSA_NAMES can have ranges
 // calculated for them on outgoing edges from basic blocks.  This represents
@@ -65,14 +108,12 @@ along with GCC; see the file COPYING3.  If not see
 //
 // The remaining routines are internal use only.
 
-class gori_compute 
+class gori_compute : public gori_map
 {
 public:
   gori_compute ();
-  ~gori_compute ();
   bool outgoing_edge_range_p (irange &r, edge e, tree name);
   bool has_edge_range_p (tree name, edge e = NULL);
-  void set_range_invariant (tree name);
   void dump (FILE *f);
 protected:
   virtual void ssa_range_in_bb (irange &r, tree name, basic_block bb);
@@ -107,7 +148,6 @@ private:
   bool compute_operand1_and_operand2_range (irange &r, gimple *stmt,
 					    const irange &lhs, tree name);
 
-  class gori_map *m_gori_map;
   gimple_outgoing_range outgoing;	// Edge values for COND_EXPR & SWITCH_EXPR.
 };


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-25 23:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-25 23:29 [gcc r12-1046] Change gori_compute to inherit from gori_map instead of having a gori-map Andrew Macleod

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).