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. */
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; }
#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
// 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.
//
// 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