diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2021-06-08 15:43:03 -0400 |
---|---|---|
committer | Andrew MacLeod <amacleod@redhat.com> | 2021-06-08 21:12:08 -0400 |
commit | 87f9ac937d6cfd81cbbe0a43518ba10781888d7c (patch) | |
tree | c23bc3c72bedad47b16ec475740ce1de5edb1629 /gcc/gimple-range.h | |
parent | 087253b9951766cbd93286b804ebb1ab59197aa8 (diff) | |
download | gcc-87f9ac937d6cfd81cbbe0a43518ba10781888d7c.zip gcc-87f9ac937d6cfd81cbbe0a43518ba10781888d7c.tar.gz gcc-87f9ac937d6cfd81cbbe0a43518ba10781888d7c.tar.bz2 |
Virtualize fur_source and turn it into a proper API.
No more accessing the local info. Also add fur_source/fold_stmt where ranges
are provided via being specified, or a vector to replace gimple_fold_range.
* gimple-range-gori.cc (gori_compute::outgoing_edge_range_p): Use a
fur_stmt source record.
* gimple-range.cc (fur_source::get_operand): Generic range query.
(fur_source::get_phi_operand): New.
(fur_source::register_dependency): New.
(fur_source::query): New.
(class fur_edge): New. Edge source for operands.
(fur_edge::fur_edge): New.
(fur_edge::get_operand): New.
(fur_edge::get_phi_operand): New.
(fur_edge::query): New.
(fur_stmt::fur_stmt): New.
(fur_stmt::get_operand): New.
(fur_stmt::get_phi_operand): New.
(fur_stmt::query): New.
(class fur_depend): New. Statement source and process dependencies.
(fur_depend::fur_depend): New.
(fur_depend::register_dependency): New.
(class fur_list): New. List source for operands.
(fur_list::fur_list): New.
(fur_list::get_operand): New.
(fur_list::get_phi_operand): New.
(fold_range): New. Instantiate appropriate fur_source class and fold.
(fold_using_range::range_of_range_op): Use new API.
(fold_using_range::range_of_address): Ditto.
(fold_using_range::range_of_phi): Ditto.
(imple_ranger::fold_range_internal): Use fur_depend class.
(fold_using_range::range_of_ssa_name_with_loop_info): Use new API.
* gimple-range.h (class fur_source): Now a base class.
(class fur_stmt): New.
(fold_range): New prototypes.
(fur_source::fur_source): Delete.
Diffstat (limited to 'gcc/gimple-range.h')
-rw-r--r-- | gcc/gimple-range.h | 101 |
1 files changed, 30 insertions, 71 deletions
diff --git a/gcc/gimple-range.h b/gcc/gimple-range.h index 02b891f..9ac779a 100644 --- a/gcc/gimple-range.h +++ b/gcc/gimple-range.h @@ -73,28 +73,45 @@ protected: ranger_cache m_cache; }; -// Source of an operand for fold_using_range. -// It can specify a stmt or and edge, or thru an internal API which uses -// the ranger cache. -// Its primary function is to retreive an operand from the source via a -// call thru the range_query object. +// Source of all operands for fold_using_range and gori_compute. +// It abstracts out the source of an operand so it can come from a stmt or +// and edge or anywhere a derived classof fur_source wants. class fur_source { - friend class fold_using_range; public: - inline fur_source (range_query *q, edge e); - inline fur_source (range_query *q, gimple *s); - inline fur_source (range_query *q, gori_compute *g, edge e, gimple *s); - bool get_operand (irange &r, tree expr); -protected: - gori_compute *m_gori; + virtual bool get_operand (irange &r, tree expr); + virtual bool get_phi_operand (irange &r, tree expr, edge e); + virtual void register_dependency (tree lhs, tree rhs); + virtual range_query *query (); +}; + +// fur_stmt is the specification for drawing an operand from range_query Q +// via a range_of_Expr call on stmt S. + +class fur_stmt : public fur_source +{ +public: + fur_stmt (gimple *s, range_query *q = NULL); + virtual bool get_operand (irange &r, tree expr) OVERRIDE; + virtual bool get_phi_operand (irange &r, tree expr, edge e) OVERRIDE; + virtual range_query *query () OVERRIDE; +private: range_query *m_query; - edge m_edge; gimple *m_stmt; }; +// Fold stmt S into range R using range query Q. +bool fold_range (irange &r, gimple *s, range_query *q = NULL); +// Recalculate stmt S into R using range query Q as if it were on edge ON_EDGE. +bool fold_range (irange &r, gimple *s, edge on_edge, range_query *q = NULL); +// These routines allow you to specify the operands to use when folding. +// Any excess queries will be drawn from the current range_query. +bool fold_range (irange &r, gimple *s, irange &r1); +bool fold_range (irange &r, gimple *s, irange &r1, irange &r2); +bool fold_range (irange &r, gimple *s, unsigned num_elements, irange *vector); + // This class uses ranges to fold a gimple statement producinf a range for // the LHS. The source of all operands is supplied via the fur_source class // which provides a range_query as well as a source location and any other @@ -119,64 +136,6 @@ protected: }; -// Create a source for a query on an edge. - -inline -fur_source::fur_source (range_query *q, edge e) -{ - m_query = q; - m_gori = NULL; - m_edge = e; - m_stmt = NULL; -} - -// Create a source for a query at a statement. - -inline -fur_source::fur_source (range_query *q, gimple *s) -{ - m_query = q; - m_gori = NULL; - m_edge = NULL; - m_stmt = s; -} - -// Create a source for Ranger. THis can recalculate from a different location -// and can also set the dependency information as appropriate when invoked. - -inline -fur_source::fur_source (range_query *q, gori_compute *g, edge e, gimple *s) -{ - m_query = q; - m_gori = g; - m_edge = e; - m_stmt = s; -} - -// Fold stmt S into range R using range query Q. - -inline bool -fold_range (irange &r, gimple *s, range_query *q = NULL) -{ - fold_using_range f; - if (q == NULL) - q = get_global_range_query (); - fur_source src (q, s); - return f.fold_stmt (r, s, src); -} - -// Recalculate stmt S into R using range query Q as if it were on edge ON_EDGE. - -inline bool -fold_range (irange &r, gimple *s, edge on_edge, range_query *q = NULL) -{ - fold_using_range f; - if (q == NULL) - q = get_global_range_query (); - fur_source src (q, on_edge); - return f.fold_stmt (r, s, src); -} - // These routines provide a GIMPLE interface to the range-ops code. extern tree gimple_range_operand1 (const gimple *s); extern tree gimple_range_operand2 (const gimple *s); |