aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-ccp.c
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2017-11-01 16:52:34 -0600
committerJeff Law <law@gcc.gnu.org>2017-11-01 16:52:34 -0600
commite10a635c274f90cc2241394b1d17e291adcbf153 (patch)
tree9ebad3083f2dd86e7aad41a9fa1673917493aea8 /gcc/tree-ssa-ccp.c
parentd9a3704a0bc83286afc179bc5e638ad6f7460bb3 (diff)
downloadgcc-e10a635c274f90cc2241394b1d17e291adcbf153.zip
gcc-e10a635c274f90cc2241394b1d17e291adcbf153.tar.gz
gcc-e10a635c274f90cc2241394b1d17e291adcbf153.tar.bz2
tree-ssa-ccp.c (ccp_folder): New class derived from substitute_and_fold_engine.
* tree-ssa-ccp.c (ccp_folder): New class derived from substitute_and_fold_engine. (ccp_folder::get_value): New member function. (ccp_folder::fold_stmt): Renamed from ccp_fold_stmt. (ccp_fold_stmt): Remove prototype. (ccp_finalize): Call substitute_and_fold from the ccp_class. * tree-ssa-copy.c (copy_folder): New class derived from substitute_and_fold_engine. (copy_folder::get_value): Renamed from get_value. (fini_copy_prop): Call substitute_and_fold from copy_folder class. * tree-vrp.c (vrp_folder): New class derived from substitute_and_fold_engine. (vrp_folder::fold_stmt): Renamed from vrp_fold_stmt. (vrp_folder::get_value): New member function. (vrp_finalize): Call substitute_and_fold from vrp_folder class. (evrp_dom_walker::before_dom_children): Similarly for replace_uses_in. * tree-ssa-propagate.h (substitute_and_fold_engine): New class to provide a class interface to folder/substitute routines. (ssa_prop_fold_stmt_fn): Remove typedef. (ssa_prop_get_value_fn): Likewise. (subsitute_and_fold): Remove prototype. (replace_uses_in): Likewise. * tree-ssa-propagate.c (substitute_and_fold_engine::replace_uses_in): Renamed from replace_uses_in. Call the virtual member function (substitute_and_fold_engine::replace_phi_args_in): Similarly. (substitute_and_fold_dom_walker): Remove initialization of data member entries for calbacks. Add substitute_and_fold_engine member and initialize it. (substitute_and_fold_dom_walker::before_dom_children0: Use the member functions for get_value, replace_phi_args_in c replace_uses_in, and fold_stmt calls. (substitute_and_fold_engine::substitute_and_fold): Renamed from substitute_and_fold. Remove assert. Update ctor call. From-SVN: r254330
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r--gcc/tree-ssa-ccp.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index d4b3623..283567c 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -188,7 +188,6 @@ static ccp_prop_value_t *const_val;
static unsigned n_const_val;
static void canonicalize_value (ccp_prop_value_t *);
-static bool ccp_fold_stmt (gimple_stmt_iterator *);
static void ccp_lattice_meet (ccp_prop_value_t *, ccp_prop_value_t *);
/* Dump constant propagation value VAL to file OUTF prefixed by PREFIX. */
@@ -909,6 +908,24 @@ do_dbg_cnt (void)
}
+/* We want to provide our own GET_VALUE and FOLD_STMT virtual methods. */
+class ccp_folder : public substitute_and_fold_engine
+{
+ public:
+ tree get_value (tree) FINAL OVERRIDE;
+ bool fold_stmt (gimple_stmt_iterator *) FINAL OVERRIDE;
+};
+
+/* This method just wraps GET_CONSTANT_VALUE for now. Over time
+ naked calls to GET_CONSTANT_VALUE should be eliminated in favor
+ of calling member functions. */
+
+tree
+ccp_folder::get_value (tree op)
+{
+ return get_constant_value (op);
+}
+
/* Do final substitution of propagated values, cleanup the flowgraph and
free allocated storage. If NONZERO_P, record nonzero bits.
@@ -967,7 +984,8 @@ ccp_finalize (bool nonzero_p)
}
/* Perform substitutions based on the known constant values. */
- something_changed = substitute_and_fold (get_constant_value, ccp_fold_stmt);
+ class ccp_folder ccp_folder;
+ something_changed = ccp_folder.substitute_and_fold ();
free (const_val);
const_val = NULL;
@@ -2176,8 +2194,8 @@ fold_builtin_alloca_with_align (gimple *stmt)
/* Fold the stmt at *GSI with CCP specific information that propagating
and regular folding does not catch. */
-static bool
-ccp_fold_stmt (gimple_stmt_iterator *gsi)
+bool
+ccp_folder::fold_stmt (gimple_stmt_iterator *gsi)
{
gimple *stmt = gsi_stmt (*gsi);