From d9a3704a0bc83286afc179bc5e638ad6f7460bb3 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Wed, 1 Nov 2017 16:49:08 -0600 Subject: tree-ssa-propagate.h (ssa_prop_visit_stmt_fn): Remove typedef. * tree-ssa-propagate.h (ssa_prop_visit_stmt_fn): Remove typedef. (ssa_prop_visit_phi_fn): Likewise. (class ssa_propagation_engine): New class to provide an interface into ssa_propagate. * tree-ssa-propagate.c (ssa_prop_visit_stmt): Remove file scoped variable. (ssa_prop_visit_phi): Likewise. (ssa_propagation_engine::simulate_stmt): Moved into class. Call visit_phi/visit_stmt from the class rather than via file scoped static variables. (ssa_propagation_engine::simulate_block): Moved into class. (ssa_propagation_engine::process_ssa_edge_worklist): Similarly. (ssa_propagation_engine::ssa_propagate): Similarly. No longer set file scoped statics for the visit_stmt/visit_phi callbacks. * tree-complex.c (complex_propagate): New class derived from ssa_propagation_engine. (complex_propagate::visit_stmt): Renamed from complex_visit_stmt. (complex_propagate::visit_phi): Renamed from complex_visit_phi. (tree_lower_complex): Call ssa_propagate via the complex_propagate class. * tree-ssa-ccp.c: (ccp_propagate): New class derived from ssa_propagation_engine. (ccp_propagate::visit_phi): Renamed from ccp_visit_phi_node. (ccp_propagate::visit_stmt): Renamed from ccp_visit_stmt. (do_ssa_ccp): Call ssa_propagate from the ccp_propagate class. * tree-ssa-copy.c (copy_prop): New class derived from ssa_propagation_engine. (copy_prop::visit_stmt): Renamed from copy_prop_visit_stmt. (copy_prop::visit_phi): Renamed from copy_prop_visit_phi_node. (execute_copy_prop): Call ssa_propagate from the copy_prop class. * tree-vrp.c (vrp_prop): New class derived from ssa_propagation_engine. (vrp_prop::visit_stmt): Renamed from vrp_visit_stmt. (vrp_prop::visit_phi): Renamed from vrp_visit_phi_node. (execute_vrp): Call ssa_propagate from the vrp_prop class. From-SVN: r254329 --- gcc/tree-ssa-propagate.h | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'gcc/tree-ssa-propagate.h') diff --git a/gcc/tree-ssa-propagate.h b/gcc/tree-ssa-propagate.h index 9a8ecc8..cff9e53 100644 --- a/gcc/tree-ssa-propagate.h +++ b/gcc/tree-ssa-propagate.h @@ -62,9 +62,6 @@ enum ssa_prop_result { /* Call-back functions used by the value propagation engine. */ -typedef enum ssa_prop_result (*ssa_prop_visit_stmt_fn) (gimple *, edge *, - tree *); -typedef enum ssa_prop_result (*ssa_prop_visit_phi_fn) (gphi *); typedef bool (*ssa_prop_fold_stmt_fn) (gimple_stmt_iterator *gsi); typedef tree (*ssa_prop_get_value_fn) (tree); @@ -73,7 +70,6 @@ extern bool valid_gimple_rhs_p (tree); extern void move_ssa_defining_stmt_for_defs (gimple *, gimple *); extern bool update_gimple_call (gimple_stmt_iterator *, tree, int, ...); extern bool update_call_from_tree (gimple_stmt_iterator *, tree); -extern void ssa_propagate (ssa_prop_visit_stmt_fn, ssa_prop_visit_phi_fn); extern bool stmt_makes_single_store (gimple *); extern bool substitute_and_fold (ssa_prop_get_value_fn, ssa_prop_fold_stmt_fn); extern bool may_propagate_copy (tree, tree); @@ -85,4 +81,27 @@ extern void propagate_tree_value (tree *, tree); extern void propagate_tree_value_into_stmt (gimple_stmt_iterator *, tree); extern bool replace_uses_in (gimple *stmt, ssa_prop_get_value_fn get_value); +/* Public interface into the SSA propagation engine. Clients should inherit + from this class and provide their own visitors. */ + +class ssa_propagation_engine +{ + public: + + /* Main interface into the propagation engine. */ + void ssa_propagate (void); + + /* Virtual functions the clients must provide to visit statements + and phi nodes respectively. */ + virtual enum ssa_prop_result visit_stmt (gimple *, edge *, tree *) = 0; + virtual enum ssa_prop_result visit_phi (gphi *) = 0; + + private: + /* Internal implementation details. */ + void simulate_stmt (gimple *stmt); + void process_ssa_edge_worklist (void); + void simulate_block (basic_block); + +}; + #endif /* _TREE_SSA_PROPAGATE_H */ -- cgit v1.1