return NULL;
}
-
// Return a TRUE or FALSE range representing the edge value of a GCOND.
void
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.
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)
}
// 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));
// 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);