Remove value_query, push into sub&fold class
* tree-ssa-propagate.cc (substitute_and_fold_engine::value_on_edge): Move from value-query.cc. (substitute_and_fold_engine::value_of_stmt): Ditto. (substitute_and_fold_engine::range_of_expr): New. * tree-ssa-propagate.h (substitute_and_fold_engine): Inherit from range_query. New prototypes. * value-query.cc (value_query::value_on_edge): Relocate. (value_query::value_of_stmt): Ditto. * value-query.h (class value_query): Remove. (class range_query): Remove base class. Adjust prototypes.
This commit is contained in:
parent
7905c071c3
commit
619641397a
4 changed files with 39 additions and 48 deletions
|
@ -532,6 +532,34 @@ struct prop_stats_d
|
|||
|
||||
static struct prop_stats_d prop_stats;
|
||||
|
||||
// range_query default methods to drive from a value_of_expr() ranther than
|
||||
// range_of_expr.
|
||||
|
||||
tree
|
||||
substitute_and_fold_engine::value_on_edge (edge, tree expr)
|
||||
{
|
||||
return value_of_expr (expr);
|
||||
}
|
||||
|
||||
tree
|
||||
substitute_and_fold_engine::value_of_stmt (gimple *stmt, tree name)
|
||||
{
|
||||
if (!name)
|
||||
name = gimple_get_lhs (stmt);
|
||||
|
||||
gcc_checking_assert (!name || name == gimple_get_lhs (stmt));
|
||||
|
||||
if (name)
|
||||
return value_of_expr (name);
|
||||
return NULL_TREE;
|
||||
}
|
||||
|
||||
bool
|
||||
substitute_and_fold_engine::range_of_expr (vrange &, tree, gimple *)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Replace USE references in statement STMT with the values stored in
|
||||
PROP_VALUE. Return true if at least one reference was replaced. */
|
||||
|
||||
|
|
|
@ -96,11 +96,17 @@ class ssa_propagation_engine
|
|||
void simulate_block (basic_block);
|
||||
};
|
||||
|
||||
class substitute_and_fold_engine : public value_query
|
||||
class substitute_and_fold_engine : public range_query
|
||||
{
|
||||
public:
|
||||
substitute_and_fold_engine (bool fold_all_stmts = false)
|
||||
: fold_all_stmts (fold_all_stmts) { }
|
||||
|
||||
virtual tree value_of_expr (tree expr, gimple * = NULL) = 0;
|
||||
virtual tree value_on_edge (edge, tree expr) override;
|
||||
virtual tree value_of_stmt (gimple *, tree name = NULL) override;
|
||||
virtual bool range_of_expr (vrange &r, tree expr, gimple * = NULL);
|
||||
|
||||
virtual ~substitute_and_fold_engine (void) { }
|
||||
virtual bool fold_stmt (gimple_stmt_iterator *) { return false; }
|
||||
|
||||
|
|
|
@ -33,27 +33,6 @@ along with GCC; see the file COPYING3. If not see
|
|||
#include "gimple-range.h"
|
||||
#include "value-range-storage.h"
|
||||
|
||||
// value_query default methods.
|
||||
|
||||
tree
|
||||
value_query::value_on_edge (edge, tree expr)
|
||||
{
|
||||
return value_of_expr (expr);
|
||||
}
|
||||
|
||||
tree
|
||||
value_query::value_of_stmt (gimple *stmt, tree name)
|
||||
{
|
||||
if (!name)
|
||||
name = gimple_get_lhs (stmt);
|
||||
|
||||
gcc_checking_assert (!name || name == gimple_get_lhs (stmt));
|
||||
|
||||
if (name)
|
||||
return value_of_expr (name);
|
||||
return NULL_TREE;
|
||||
}
|
||||
|
||||
// range_query default methods.
|
||||
|
||||
bool
|
||||
|
|
|
@ -37,28 +37,6 @@ along with GCC; see the file COPYING3. If not see
|
|||
// Proper usage of the correct query in passes will enable other
|
||||
// valuation mechanisms to produce more precise results.
|
||||
|
||||
class value_query
|
||||
{
|
||||
public:
|
||||
value_query () { }
|
||||
// Return the singleton expression for EXPR at a gimple statement,
|
||||
// or NULL if none found.
|
||||
virtual tree value_of_expr (tree expr, gimple * = NULL) = 0;
|
||||
// Return the singleton expression for EXPR at an edge, or NULL if
|
||||
// none found.
|
||||
virtual tree value_on_edge (edge, tree expr);
|
||||
// Return the singleton expression for the LHS of a gimple
|
||||
// statement, assuming an (optional) initial value of NAME. Returns
|
||||
// NULL if none found.
|
||||
//
|
||||
// Note that this method calculates the range the LHS would have
|
||||
// *after* the statement has executed.
|
||||
virtual tree value_of_stmt (gimple *, tree name = NULL);
|
||||
|
||||
private:
|
||||
DISABLE_COPY_AND_ASSIGN (value_query);
|
||||
};
|
||||
|
||||
// The range_query class is used by optimization passes which are
|
||||
// range aware.
|
||||
//
|
||||
|
@ -73,15 +51,15 @@ private:
|
|||
// The get_value_range method is currently provided for compatibility
|
||||
// with vr-values. It will be deprecated when possible.
|
||||
|
||||
class range_query : public value_query
|
||||
class range_query
|
||||
{
|
||||
public:
|
||||
range_query ();
|
||||
virtual ~range_query ();
|
||||
|
||||
virtual tree value_of_expr (tree expr, gimple * = NULL) override;
|
||||
virtual tree value_on_edge (edge, tree expr) override;
|
||||
virtual tree value_of_stmt (gimple *, tree name = NULL) override;
|
||||
virtual tree value_of_expr (tree expr, gimple * = NULL);
|
||||
virtual tree value_on_edge (edge, tree expr);
|
||||
virtual tree value_of_stmt (gimple *, tree name = NULL);
|
||||
|
||||
// These are the range equivalents of the value_* methods. Instead
|
||||
// of returning a singleton, they calculate a range and return it in
|
||||
|
|
Loading…
Add table
Reference in a new issue