// -------------------------------------------------------------------------
-// Initialize a global cache.
+// Initialize an ssa cache.
-ssa_global_cache::ssa_global_cache ()
+ssa_cache::ssa_cache ()
{
m_tab.create (0);
m_range_allocator = new obstack_vrange_allocator;
}
-// Deconstruct a global cache.
+// Deconstruct an ssa cache.
-ssa_global_cache::~ssa_global_cache ()
+ssa_cache::~ssa_cache ()
{
m_tab.release ();
delete m_range_allocator;
}
+// Return TRUE if the global range of NAME has a cache entry.
+
+bool
+ssa_cache::has_range (tree name) const
+{
+ unsigned v = SSA_NAME_VERSION (name);
+ if (v >= m_tab.length ())
+ return false;
+ return m_tab[v] != NULL;
+}
+
// Retrieve the global range of NAME from cache memory if it exists.
// Return the value in R.
bool
-ssa_global_cache::get_global_range (vrange &r, tree name) const
+ssa_cache::get_range (vrange &r, tree name) const
{
unsigned v = SSA_NAME_VERSION (name);
if (v >= m_tab.length ())
return true;
}
-// Set the range for NAME to R in the global cache.
+// Set the range for NAME to R in the ssa cache.
// Return TRUE if there was already a range set, otherwise false.
bool
-ssa_global_cache::set_global_range (tree name, const vrange &r)
+ssa_cache::set_range (tree name, const vrange &r)
{
unsigned v = SSA_NAME_VERSION (name);
if (v >= m_tab.length ())
// Set the range for NAME to R in the global cache.
void
-ssa_global_cache::clear_global_range (tree name)
+ssa_cache::clear_range (tree name)
{
unsigned v = SSA_NAME_VERSION (name);
if (v >= m_tab.length ())
m_tab[v] = NULL;
}
-// Clear the global cache.
+// Clear the ssa cache.
void
-ssa_global_cache::clear ()
+ssa_cache::clear ()
{
if (m_tab.address ())
memset (m_tab.address(), 0, m_tab.length () * sizeof (vrange *));
}
-// Dump the contents of the global cache to F.
+// Dump the contents of the ssa cache to F.
void
-ssa_global_cache::dump (FILE *f)
+ssa_cache::dump (FILE *f)
{
/* Cleared after the table header has been printed. */
bool print_header = true;
if (!gimple_range_ssa_p (ssa_name (x)))
continue;
Value_Range r (TREE_TYPE (ssa_name (x)));
- if (get_global_range (r, ssa_name (x)) && !r.varying_p ())
+ if (get_range (r, ssa_name (x)) && !r.varying_p ())
{
if (print_header)
{
bool
ranger_cache::get_global_range (vrange &r, tree name) const
{
- if (m_globals.get_global_range (r, name))
+ if (m_globals.get_range (r, name))
return true;
gimple_range_global (r, name);
return false;
|| m_temporal->current_p (name, m_gori.depend1 (name),
m_gori.depend2 (name));
else
- m_globals.set_global_range (name, r);
+ m_globals.set_range (name, r);
// If the existing value was not current, mark it as always current.
if (!current_p)
void
ranger_cache::set_global_range (tree name, const vrange &r)
{
- if (m_globals.set_global_range (name, r))
+ if (m_globals.set_range (name, r))
{
// If there was already a range set, propagate the new value.
basic_block bb = gimple_bb (SSA_NAME_DEF_STMT (name));
gcc_checking_assert (!bb || bb == gimple_bb (SSA_NAME_DEF_STMT (name)));
// Pick up the best global range available.
- if (!m_globals.get_global_range (r, name))
+ if (!m_globals.get_range (r, name))
{
// If that fails, try to calculate the range using just global values.
gimple *s = SSA_NAME_DEF_STMT (name);
// has been visited during this incarnation. Once the ranger evaluates
// a name, it is typically not re-evaluated again.
-class ssa_global_cache
+class ssa_cache
{
public:
- ssa_global_cache ();
- ~ssa_global_cache ();
- bool get_global_range (vrange &r, tree name) const;
- bool set_global_range (tree name, const vrange &r);
- void clear_global_range (tree name);
+ ssa_cache ();
+ ~ssa_cache ();
+ bool has_range (tree name) const;
+ bool get_range (vrange &r, tree name) const;
+ bool set_range (tree name, const vrange &r);
+ void clear_range (tree name);
void clear ();
void dump (FILE *f = stderr);
private:
void dump_bb (FILE *f, basic_block bb);
virtual void dump (FILE *f) override;
private:
- ssa_global_cache m_globals;
+ ssa_cache m_globals;
block_range_cache m_on_entry;
class temporal_cache *m_temporal;
void fill_block_cache (tree name, basic_block bb, basic_block def_bb);
const vec<basic_block> &path,
const bitmap_head *dependencies,
bool resolve)
- : m_cache (new ssa_global_cache),
+ : m_cache (new ssa_cache),
m_has_cache_entry (BITMAP_ALLOC (NULL)),
m_ranger (ranger),
m_resolve (resolve)
}
path_range_query::path_range_query (gimple_ranger &ranger, bool resolve)
- : m_cache (new ssa_global_cache),
+ : m_cache (new ssa_cache),
m_has_cache_entry (BITMAP_ALLOC (NULL)),
m_ranger (ranger),
m_resolve (resolve)
unsigned v = SSA_NAME_VERSION (name);
if (bitmap_bit_p (m_has_cache_entry, v))
- return m_cache->get_global_range (r, name);
+ return m_cache->get_range (r, name);
return false;
}
{
unsigned v = SSA_NAME_VERSION (name);
bitmap_set_bit (m_has_cache_entry, v);
- m_cache->set_global_range (name, r);
+ m_cache->set_range (name, r);
}
void
void move_next () { --m_pos; }
// Range cache for SSA names.
- ssa_global_cache *m_cache;
+ ssa_cache *m_cache;
// Set for each SSA that has an active entry in the cache.
bitmap m_has_cache_entry;
bool
assume_query::assume_range_p (vrange &r, tree name)
{
- if (global.get_global_range (r, name))
+ if (global.get_range (r, name))
return !r.varying_p ();
return false;
}
if (!gimple_range_ssa_p (expr))
return get_tree_range (r, expr, stmt);
- if (!global.get_global_range (r, expr))
+ if (!global.get_range (r, expr))
r.set_varying (TREE_TYPE (expr));
return true;
}
unsigned prec = TYPE_PRECISION (lhs_type);
int_range<2> lhs_range (lhs_type, wi::one (prec), wi::one (prec));
- global.set_global_range (op, lhs_range);
+ global.set_range (op, lhs_range);
gimple *def = SSA_NAME_DEF_STMT (op);
if (!def || gimple_get_lhs (def) != op)
&& !op_range.varying_p ())
{
Value_Range range (TREE_TYPE (op));
- if (global.get_global_range (range, op))
+ if (global.get_range (range, op))
op_range.intersect (range);
- global.set_global_range (op, op_range);
+ global.set_range (op, op_range);
gimple *def_stmt = SSA_NAME_DEF_STMT (op);
if (def_stmt && gimple_get_lhs (def_stmt) == op)
calculate_stmt (def_stmt, op_range, src);
// A symbol arg will be the LHS value.
arg_range = lhs_range;
range_cast (arg_range, TREE_TYPE (arg));
- if (!global.get_global_range (arg_range, arg))
+ if (!global.get_range (arg_range, arg))
{
- global.set_global_range (arg, arg_range);
+ global.set_range (arg, arg_range);
gimple *def_stmt = SSA_NAME_DEF_STMT (arg);
if (def_stmt && gimple_get_lhs (def_stmt) == arg)
calculate_stmt (def_stmt, arg_range, src);
void calculate_phi (gphi *phi, vrange &lhs_range, fur_source &src);
void check_taken_edge (edge e, fur_source &src);
- ssa_global_cache global;
+ ssa_cache global;
gori_compute m_gori;
};