diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2024-05-06 12:04:24 -0400 |
---|---|---|
committer | Andrew MacLeod <amacleod@redhat.com> | 2024-05-23 16:48:44 -0400 |
commit | 76153635b9dc811b3ddc2c2e028d74c92d174c2e (patch) | |
tree | 1b3c95993228b578ee81fddb5a7e60fa26698b41 /gcc | |
parent | efc4255d4393cba3d2232a7152799e1b161c3062 (diff) | |
download | gcc-76153635b9dc811b3ddc2c2e028d74c92d174c2e.zip gcc-76153635b9dc811b3ddc2c2e028d74c92d174c2e.tar.gz gcc-76153635b9dc811b3ddc2c2e028d74c92d174c2e.tar.bz2 |
Default gimple_outgoing_range to not process switches.
Change the default constructor to not process switches, add method to
enable/disable switch processing.
* gimple-range-edge.cc (gimple_outgoing_range::gimple_outgoing_range):
Do not allocate a range allocator at construction time.
(gimple_outgoing_range::~gimple_outgoing_range): Delete allocator
if one was allocated.
(gimple_outgoing_range::set_switch_limit): New.
(gimple_outgoing_range::switch_edge_range): Create an allocator if one
does not exist.
(gimple_outgoing_range::edge_range_p): Check for zero edges.
* gimple-range-edge.h (class gimple_outgoing_range): Adjust prototypes.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/gimple-range-edge.cc | 23 | ||||
-rw-r--r-- | gcc/gimple-range-edge.h | 12 |
2 files changed, 28 insertions, 7 deletions
diff --git a/gcc/gimple-range-edge.cc b/gcc/gimple-range-edge.cc index 3811a09..0c75ad0 100644 --- a/gcc/gimple-range-edge.cc +++ b/gcc/gimple-range-edge.cc @@ -51,7 +51,6 @@ gimple_outgoing_range_stmt_p (basic_block bb) return NULL; } - // Return a TRUE or FALSE range representing the edge value of a GCOND. void @@ -64,22 +63,32 @@ gcond_edge_range (irange &r, edge e) r = range_false (); } +// Construct a gimple_outgoing_range object. No memory is allocated. gimple_outgoing_range::gimple_outgoing_range (int max_sw_edges) { m_edge_table = NULL; + m_range_allocator = NULL; m_max_edges = max_sw_edges; - m_range_allocator = new vrange_allocator; } +// Destruct an edge object, disposing of any memory allocated. gimple_outgoing_range::~gimple_outgoing_range () { if (m_edge_table) delete m_edge_table; - delete m_range_allocator; + if (m_range_allocator) + delete m_range_allocator; } +// Set a new switch limit. + +void +gimple_outgoing_range::set_switch_limit (int max_sw_edges) +{ + m_max_edges = max_sw_edges; +} // Get a range for a switch edge E from statement S and return it in R. // Use a cached value if it exists, or calculate it if not. @@ -96,8 +105,10 @@ gimple_outgoing_range::switch_edge_range (irange &r, gswitch *sw, edge e) TYPE_PRECISION (TREE_TYPE (gimple_switch_index (sw)))) return false; - if (!m_edge_table) - m_edge_table = new hash_map<edge, vrange_storage *> (n_edges_for_fn (cfun)); + if (!m_edge_table) + m_edge_table = new hash_map<edge, vrange_storage *> (n_edges_for_fn (cfun)); + if (!m_range_allocator) + m_range_allocator = new vrange_allocator; vrange_storage **val = m_edge_table->get (e); if (!val) @@ -202,7 +213,7 @@ gimple_outgoing_range::edge_range_p (irange &r, edge e) } // Only process switches if it within the size limit. - if (EDGE_COUNT (e->src->succs) > (unsigned)m_max_edges) + if (m_max_edges == 0 || (EDGE_COUNT (e->src->succs) > (unsigned)m_max_edges)) return NULL; gcc_checking_assert (is_a<gswitch *> (s)); diff --git a/gcc/gimple-range-edge.h b/gcc/gimple-range-edge.h index 9ac0617..ce8b04f 100644 --- a/gcc/gimple-range-edge.h +++ b/gcc/gimple-range-edge.h @@ -34,13 +34,23 @@ along with GCC; see the file COPYING3. If not see // The API is simple, just ask for the range on the edge. // The return value is NULL for no range, or the branch statement which the // edge gets the range from, along with the range. +// +// THe switch_limit is the number of switch edges beyond which the switch +// is ignored (ie, edge_range_p () will return NULL as if the sitch was not +// there. THis value can be adjusted any time via set_switch_limit (). +// THe default is 0, no switches are precoessed until set_switch_limit () is +// called, and then the default is INT_MAX. +// +// No memory is allocated until an edge for a switch is processed which also +// falls under the edge limit criteria. class gimple_outgoing_range { public: - gimple_outgoing_range (int max_sw_edges = INT_MAX); + gimple_outgoing_range (int max_sw_edges = 0); ~gimple_outgoing_range (); gimple *edge_range_p (irange &r, edge e); + void set_switch_limit (int max_sw_edges = INT_MAX); private: void calc_switch_ranges (gswitch *sw); bool switch_edge_range (irange &r, gswitch *sw, edge e); |