From 3a5b702c4082950d614fe12a066609da23363246 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Fri, 17 May 2024 10:18:39 -0400
Subject: [PATCH 03/12] Rename relation oracle and API.
With more oracles incoming, rename the range_query oracle () method to
relation (), and remove the redundant 'relation' text from register and query
methods, resulting in calls that look like:
relation ()->record (...) and
relation ()->query (...)
* gimple-range-cache.cc (ranger_cache::dump_bb): Use m_relation.
(ranger_cache::fill_block_cache): Likewise
* gimple-range-fold.cc (fur_stmt::get_phi_operand): Use new names.
(fur_depend::register_relation): Likewise.
(fold_using_range::range_of_phi): Likewise.
* gimple-range-path.cc (path_range_query::path_range_query): Likewise.
(path_range_query::~path_range_query): Likewise.
(ath_range_query::compute_ranges): Likewise.
(jt_fur_source::register_relation): Likewise.
(jt_fur_source::query_relation): Likewise.
(path_range_query::maybe_register_phi_relation): Likewise.
* gimple-range-path.h (get_path_oracle): Likewise.
* value-query.cc (range_query::create_relation_oracle): Likewise.
(range_query::destroy_relation_oracle): Likewise.
(range_query::share_oracles): Likewise.
(range_query::range_query): Likewise.
* value-query.h (value_query::relation): Rename from oracle.
(m_relation): Rename from m_oracle.
* value-relation.cc (relation_oracle::query): Rename from
query_relation.
(equiv_oracle::query): Likewise.
(equiv_oracle::record): Rename from register_relation.
(relation_oracle::record): Likewise.
(dom_oracle::record): Likewise.
(dom_oracle::query): Rename from query_relation.
(path_oracle::record): Rename from register_relation.
(path_oracle::query): Rename from query_relation.
* value-relation.h (*::record): Rename from register_relation.
(*::query): Rename from query_relation.
---
gcc/gimple-range-cache.cc | 4 +--
gcc/gimple-range-fold.cc | 10 ++++----
gcc/gimple-range-path.cc | 18 +++++++-------
gcc/gimple-range-path.h | 2 +-
gcc/gimple-range.cc | 4 +--
gcc/value-query.cc | 16 ++++++------
gcc/value-query.h | 4 +--
gcc/value-relation.cc | 51 ++++++++++++++++++---------------------
gcc/value-relation.h | 39 +++++++++++++-----------------
9 files changed, 69 insertions(+), 79 deletions(-)
@@ -1001,7 +1001,7 @@ ranger_cache::dump_bb (FILE *f, basic_block bb)
{
m_gori.gori_map::dump (f, bb, false);
m_on_entry.dump (f, bb);
- m_oracle->dump (f, bb);
+ m_relation->dump (f, bb);
}
// Get the global range for NAME, and return in R. Return false if the
@@ -1439,7 +1439,7 @@ ranger_cache::fill_block_cache (tree name, basic_block bb, basic_block def_bb)
tree equiv_name;
relation_kind rel;
int prec = TYPE_PRECISION (type);
- FOR_EACH_PARTIAL_AND_FULL_EQUIV (m_oracle, bb, name, equiv_name, rel)
+ FOR_EACH_PARTIAL_AND_FULL_EQUIV (m_relation, bb, name, equiv_name, rel)
{
basic_block equiv_bb = gimple_bb (SSA_NAME_DEF_STMT (equiv_name));
@@ -178,7 +178,7 @@ fur_stmt::get_phi_operand (vrange &r, tree expr, edge e)
relation_kind
fur_stmt::query_relation (tree op1, tree op2)
{
- return m_query->oracle ().query_relation (m_stmt, op1, op2);
+ return m_query->relation ().query (m_stmt, op1, op2);
}
// Instantiate a stmt based fur_source with a GORI object.
@@ -196,7 +196,7 @@ fur_depend::fur_depend (gimple *s, gori_compute *gori, range_query *q)
void
fur_depend::register_relation (gimple *s, relation_kind k, tree op1, tree op2)
{
- m_query->oracle ().register_relation (s, k, op1, op2);
+ m_query->relation ().record (s, k, op1, op2);
}
// Register a relation on an edge if there is an oracle.
@@ -204,7 +204,7 @@ fur_depend::register_relation (gimple *s, relation_kind k, tree op1, tree op2)
void
fur_depend::register_relation (edge e, relation_kind k, tree op1, tree op2)
{
- m_query->oracle ().register_relation (e, k, op1, op2);
+ m_query->relation ().record (e, k, op1, op2);
}
// This version of fur_source will pick a range up from a list of ranges
@@ -854,7 +854,7 @@ fold_using_range::range_of_phi (vrange &r, gphi *phi, fur_source &src)
tree single_arg = NULL_TREE;
bool seen_arg = false;
- relation_oracle *oracle = &(src.query()->oracle ());
+ relation_oracle *oracle = &(src.query()->relation ());
// Start with an empty range, unioning in each argument's range.
r.set_undefined ();
for (x = 0; x < gimple_phi_num_args (phi); x++)
@@ -875,7 +875,7 @@ fold_using_range::range_of_phi (vrange &r, gphi *phi, fur_source &src)
// Likewise, if the incoming PHI argument is equivalent to this
// PHI definition, it provides no new info. Accumulate these ranges
// in case all arguments are equivalences.
- if (oracle->query_relation (e, arg, phi_def) == VREL_EQ)
+ if (oracle->query (e, arg, phi_def) == VREL_EQ)
equiv_range.union_(arg_range);
else
r.union_ (arg_range);
@@ -44,7 +44,7 @@ path_range_query::path_range_query (gimple_ranger &ranger,
m_ranger (ranger),
m_resolve (resolve)
{
- m_oracle = new path_oracle (&(m_ranger.oracle ()));
+ m_relation = new path_oracle (&(m_ranger.relation ()));
reset_path (path, dependencies);
}
@@ -54,13 +54,13 @@ path_range_query::path_range_query (gimple_ranger &ranger, bool resolve)
m_ranger (ranger),
m_resolve (resolve)
{
- m_oracle = new path_oracle (&(m_ranger.oracle ()));
+ m_relation = new path_oracle (&(m_ranger.relation ()));
}
path_range_query::~path_range_query ()
{
- delete m_oracle;
- m_oracle = NULL;
+ delete m_relation;
+ m_relation = NULL;
}
// Return TRUE if NAME is an exit dependency for the path.
@@ -563,7 +563,7 @@ path_range_query::compute_ranges (const bitmap_head *dependencies)
if (m_resolve)
{
path_oracle *p = get_path_oracle ();
- p->reset_path (&(m_ranger.oracle ()));
+ p->reset_path (&(m_ranger.relation ()));
}
if (DEBUG_SOLVER)
@@ -636,7 +636,7 @@ jt_fur_source::jt_fur_source (gimple *s,
void
jt_fur_source::register_relation (gimple *, relation_kind k, tree op1, tree op2)
{
- m_query->oracle ().register_relation (m_entry, k, op1, op2);
+ m_query->relation ().record (m_entry, k, op1, op2);
}
// Ignore edge and register relation on entry to path.
@@ -644,7 +644,7 @@ jt_fur_source::register_relation (gimple *, relation_kind k, tree op1, tree op2)
void
jt_fur_source::register_relation (edge, relation_kind k, tree op1, tree op2)
{
- m_query->oracle ().register_relation (m_entry, k, op1, op2);
+ m_query->relation ().record (m_entry, k, op1, op2);
}
relation_kind
@@ -653,7 +653,7 @@ jt_fur_source::query_relation (tree op1, tree op2)
if (TREE_CODE (op1) != SSA_NAME || TREE_CODE (op2) != SSA_NAME)
return VREL_VARYING;
- return m_query->oracle().query_relation (m_entry, op1, op2);
+ return m_query->relation ().query (m_entry, op1, op2);
}
// Return the range of STMT at the end of the path being analyzed.
@@ -707,7 +707,7 @@ path_range_query::maybe_register_phi_relation (gphi *phi, edge e)
fprintf (dump_file, "maybe_register_phi_relation in bb%d:", bb->index);
get_path_oracle ()->killing_def (result);
- m_oracle->register_relation (entry_bb (), VREL_EQ, arg, result);
+ m_relation->record (entry_bb (), VREL_EQ, arg, result);
}
// Compute relations for each PHI in BB. For example:
@@ -51,7 +51,7 @@ private:
void compute_exit_dependencies (bitmap_head *dependencies);
bool defined_outside_path (tree name);
void range_on_path_entry (vrange &r, tree name);
- path_oracle *get_path_oracle () { return (path_oracle *)m_oracle; }
+ path_oracle *get_path_oracle () { return (path_oracle *)m_relation; }
// Cache manipulation.
bool get_cache (vrange &r, tree name);
@@ -44,7 +44,7 @@ gimple_ranger::gimple_ranger (bool use_imm_uses) :
current_bb (NULL)
{
// Share the oracle from the cache.
- m_oracle = &m_cache.oracle ();
+ m_relation = &m_cache.relation ();
if (dump_file && (param_ranger_debug & RANGER_DEBUG_TRACE))
tracer.enable_trace ();
m_stmt_list.create (0);
@@ -68,7 +68,7 @@ gimple_ranger::gimple_ranger (bool use_imm_uses) :
gimple_ranger::~gimple_ranger ()
{
// Restore the original oracle.
- m_oracle = NULL;
+ m_relation = NULL;
m_stmt_list.release ();
}
@@ -189,12 +189,12 @@ void
range_query::create_relation_oracle ()
{
gcc_checking_assert (this != &global_ranges);
- gcc_checking_assert (m_oracle == &default_relation_oracle);
+ gcc_checking_assert (m_relation == &default_relation_oracle);
if (!dom_info_available_p (CDI_DOMINATORS))
return;
- m_oracle = new dom_oracle ();
- gcc_checking_assert (m_oracle);
+ m_relation = new dom_oracle ();
+ gcc_checking_assert (m_relation);
}
// Destroy any relation oracle that was created.
@@ -202,18 +202,18 @@ range_query::create_relation_oracle ()
void
range_query::destroy_relation_oracle ()
{
- // m_oracle can be NULL if a derived range_query class took care of
+ // m_relation can be NULL if a derived range_query class took care of
// disposing its own oracle.
- if (m_oracle && m_oracle != &default_relation_oracle)
+ if (m_relation && m_relation != &default_relation_oracle)
{
- delete m_oracle;
- m_oracle = &default_relation_oracle;
+ delete m_relation;
+ m_relation = &default_relation_oracle;
}
}
range_query::range_query ()
{
- m_oracle = &default_relation_oracle;
+ m_relation = &default_relation_oracle;
}
range_query::~range_query ()
@@ -75,7 +75,7 @@ public:
virtual bool range_on_entry (vrange &r, basic_block bb, tree expr);
virtual bool range_on_exit (vrange &r, basic_block bb, tree expr);
- inline class relation_oracle &oracle () const { return *m_oracle; }
+ inline class relation_oracle &relation () const { return *m_relation; }
void create_relation_oracle ();
void destroy_relation_oracle ();
@@ -87,7 +87,7 @@ protected:
bool invoke_range_of_expr (vrange &v, tree expr, gimple *stmt,
basic_block bbentry, basic_block bbexit);
bool get_arith_expr_range (vrange &r, tree expr, gimple *stmt);
- relation_oracle *m_oracle;
+ relation_oracle *m_relation;
};
// Global ranges for SSA names using SSA_NAME_RANGE_INFO.
@@ -233,11 +233,11 @@ relation_oracle::valid_equivs (bitmap b, const_bitmap equivs, basic_block bb)
// the definitions have been processed and any relations have be created.
relation_kind
-relation_oracle::query_relation (gimple *s, tree ssa1, tree ssa2)
+relation_oracle::query (gimple *s, tree ssa1, tree ssa2)
{
if (TREE_CODE (ssa1) != SSA_NAME || TREE_CODE (ssa2) != SSA_NAME)
return VREL_VARYING;
- return query_relation (gimple_bb (s), ssa1, ssa2);
+ return query (gimple_bb (s), ssa1, ssa2);
}
// Return any known relation between SSA1 and SSA2 on edge E.
@@ -245,7 +245,7 @@ relation_oracle::query_relation (gimple *s, tree ssa1, tree ssa2)
// the definitions have been processed and any relations have be created.
relation_kind
-relation_oracle::query_relation (edge e, tree ssa1, tree ssa2)
+relation_oracle::query (edge e, tree ssa1, tree ssa2)
{
basic_block bb;
if (TREE_CODE (ssa1) != SSA_NAME || TREE_CODE (ssa2) != SSA_NAME)
@@ -259,7 +259,7 @@ relation_oracle::query_relation (edge e, tree ssa1, tree ssa2)
else
bb = e->dest;
- return query_relation (bb, ssa1, ssa2);
+ return query (bb, ssa1, ssa2);
}
// -------------------------------------------------------------------------
@@ -478,7 +478,7 @@ equiv_oracle::equiv_set (tree ssa, basic_block bb)
// Query if there is a relation (equivalence) between 2 SSA_NAMEs.
relation_kind
-equiv_oracle::query_relation (basic_block bb, tree ssa1, tree ssa2)
+equiv_oracle::query (basic_block bb, tree ssa1, tree ssa2)
{
// If the 2 ssa names share the same equiv set, they are equal.
if (equiv_set (ssa1, bb) == equiv_set (ssa2, bb))
@@ -491,8 +491,8 @@ equiv_oracle::query_relation (basic_block bb, tree ssa1, tree ssa2)
// Query if there is a relation (equivalence) between 2 SSA_NAMEs.
relation_kind
-equiv_oracle::query_relation (basic_block bb ATTRIBUTE_UNUSED, const_bitmap e1,
- const_bitmap e2)
+equiv_oracle::query (basic_block bb ATTRIBUTE_UNUSED, const_bitmap e1,
+ const_bitmap e2)
{
// If the 2 ssa names share the same equiv set, they are equal.
if (bitmap_equal_p (e1, e2))
@@ -624,8 +624,7 @@ equiv_oracle::register_initial_def (tree ssa)
// containing all the ssa_names in this basic block.
void
-equiv_oracle::register_relation (basic_block bb, relation_kind k, tree ssa1,
- tree ssa2)
+equiv_oracle::record (basic_block bb, relation_kind k, tree ssa1, tree ssa2)
{
// Process partial equivalencies.
if (relation_partial_equiv_p (k))
@@ -998,8 +997,7 @@ dom_oracle::~dom_oracle ()
// Register relation K between ssa_name OP1 and OP2 on STMT.
void
-relation_oracle::register_relation (gimple *stmt, relation_kind k, tree op1,
- tree op2)
+relation_oracle::record (gimple *stmt, relation_kind k, tree op1, tree op2)
{
gcc_checking_assert (TREE_CODE (op1) == SSA_NAME);
gcc_checking_assert (TREE_CODE (op2) == SSA_NAME);
@@ -1040,13 +1038,13 @@ relation_oracle::register_relation (gimple *stmt, relation_kind k, tree op1,
return;
}
}
- register_relation (gimple_bb (stmt), k, op1, op2);
+ record (gimple_bb (stmt), k, op1, op2);
}
// Register relation K between ssa_name OP1 and OP2 on edge E.
void
-relation_oracle::register_relation (edge e, relation_kind k, tree op1, tree op2)
+relation_oracle::record (edge e, relation_kind k, tree op1, tree op2)
{
gcc_checking_assert (TREE_CODE (op1) == SSA_NAME);
gcc_checking_assert (TREE_CODE (op2) == SSA_NAME);
@@ -1064,7 +1062,7 @@ relation_oracle::register_relation (edge e, relation_kind k, tree op1, tree op2)
fprintf (dump_file, " on (%d->%d)\n", e->src->index, e->dest->index);
}
- register_relation (e->dest, k, op1, op2);
+ record (e->dest, k, op1, op2);
}
// Register relation K between OP! and OP2 in block BB.
@@ -1072,8 +1070,7 @@ relation_oracle::register_relation (edge e, relation_kind k, tree op1, tree op2)
// tree to merge with.
void
-dom_oracle::register_relation (basic_block bb, relation_kind k, tree op1,
- tree op2)
+dom_oracle::record (basic_block bb, relation_kind k, tree op1, tree op2)
{
// If the 2 ssa_names are the same, do nothing. An equivalence is implied,
// and no other relation makes sense.
@@ -1082,7 +1079,7 @@ dom_oracle::register_relation (basic_block bb, relation_kind k, tree op1,
// Equivalencies are handled by the equivalence oracle.
if (relation_equiv_p (k))
- equiv_oracle::register_relation (bb, k, op1, op2);
+ equiv_oracle::record (bb, k, op1, op2);
else
{
// if neither op1 nor op2 are in a relation before this is registered,
@@ -1283,8 +1280,7 @@ dom_oracle::find_relation_block (unsigned bb, const_bitmap b1,
// and B2, starting with block BB.
relation_kind
-dom_oracle::query_relation (basic_block bb, const_bitmap b1,
- const_bitmap b2)
+dom_oracle::query (basic_block bb, const_bitmap b1, const_bitmap b2)
{
relation_kind r;
if (bitmap_equal_p (b1, b2))
@@ -1371,7 +1367,7 @@ dom_oracle::find_relation_dom (basic_block bb, unsigned v1, unsigned v2) const
// dominator of BB
relation_kind
-dom_oracle::query_relation (basic_block bb, tree ssa1, tree ssa2)
+dom_oracle::query (basic_block bb, tree ssa1, tree ssa2)
{
relation_kind kind;
unsigned v1 = SSA_NAME_VERSION (ssa1);
@@ -1401,7 +1397,7 @@ dom_oracle::query_relation (basic_block bb, tree ssa1, tree ssa2)
return kind;
// Query using the equivalence sets.
- kind = query_relation (bb, equiv1, equiv2);
+ kind = query (bb, equiv1, equiv2);
return kind;
}
@@ -1565,8 +1561,7 @@ path_oracle::killing_def (tree ssa)
// querying from BB.
void
-path_oracle::register_relation (basic_block bb, relation_kind k, tree ssa1,
- tree ssa2)
+path_oracle::record (basic_block bb, relation_kind k, tree ssa1, tree ssa2)
{
// If the 2 ssa_names are the same, do nothing. An equivalence is implied,
// and no other relation makes sense.
@@ -1581,7 +1576,7 @@ path_oracle::register_relation (basic_block bb, relation_kind k, tree ssa1,
fprintf (dump_file, " (root: bb%d)\n", bb->index);
}
- relation_kind curr = query_relation (bb, ssa1, ssa2);
+ relation_kind curr = query (bb, ssa1, ssa2);
if (curr != VREL_VARYING)
k = relation_intersect (curr, k);
@@ -1604,7 +1599,7 @@ path_oracle::register_relation (basic_block bb, relation_kind k, tree ssa1,
// starting at block BB.
relation_kind
-path_oracle::query_relation (basic_block bb, const_bitmap b1, const_bitmap b2)
+path_oracle::query (basic_block bb, const_bitmap b1, const_bitmap b2)
{
if (bitmap_equal_p (b1, b2))
return VREL_EQ;
@@ -1618,7 +1613,7 @@ path_oracle::query_relation (basic_block bb, const_bitmap b1, const_bitmap b2)
return k;
if (k == VREL_VARYING && m_root)
- k = m_root->query_relation (bb, b1, b2);
+ k = m_root->query (bb, b1, b2);
return k;
}
@@ -1627,7 +1622,7 @@ path_oracle::query_relation (basic_block bb, const_bitmap b1, const_bitmap b2)
// starting at block BB.
relation_kind
-path_oracle::query_relation (basic_block bb, tree ssa1, tree ssa2)
+path_oracle::query (basic_block bb, tree ssa1, tree ssa2)
{
unsigned v1 = SSA_NAME_VERSION (ssa1);
unsigned v2 = SSA_NAME_VERSION (ssa2);
@@ -1640,7 +1635,7 @@ path_oracle::query_relation (basic_block bb, tree ssa1, tree ssa2)
if (bitmap_bit_p (equiv_1, v2) && bitmap_bit_p (equiv_2, v1))
return VREL_EQ;
- return query_relation (bb, equiv_1, equiv_2);
+ return query (bb, equiv_1, equiv_2);
}
// Reset any relations registered on this path. ORACLE is the root
@@ -100,15 +100,14 @@ public:
virtual ~relation_oracle () { }
// register a relation between 2 ssa names.
- void register_relation (gimple *, relation_kind, tree, tree);
- void register_relation (edge, relation_kind, tree, tree);
- virtual void register_relation (basic_block, relation_kind, tree, tree) { }
+ void record (gimple *, relation_kind, tree, tree);
+ void record (edge, relation_kind, tree, tree);
+ virtual void record (basic_block, relation_kind, tree, tree) { }
// Query if there is any relation between SSA1 and SSA2.
- relation_kind query_relation (gimple *s, tree ssa1, tree ssa2);
- relation_kind query_relation (edge e, tree ssa1, tree ssa2);
- virtual relation_kind query_relation (basic_block, tree, tree)
- { return VREL_VARYING; }
+ relation_kind query (gimple *s, tree ssa1, tree ssa2);
+ relation_kind query (edge e, tree ssa1, tree ssa2);
+ virtual relation_kind query (basic_block, tree, tree) { return VREL_VARYING; }
virtual void dump (FILE *, basic_block) const { }
virtual void dump (FILE *) const { }
@@ -121,8 +120,8 @@ protected:
virtual const class pe_slice *partial_equiv_set (tree) { return NULL; }
void valid_equivs (bitmap b, const_bitmap equivs, basic_block bb);
// Query for a relation between two equivalency sets in a basic block.
- virtual relation_kind query_relation (basic_block, const_bitmap,
- const_bitmap) { return VREL_VARYING; }
+ virtual relation_kind query (basic_block, const_bitmap, const_bitmap)
+ { return VREL_VARYING; }
friend class path_oracle;
};
@@ -162,13 +161,11 @@ public:
~equiv_oracle ();
const_bitmap equiv_set (tree ssa, basic_block bb) final override;
- void register_relation (basic_block bb, relation_kind k, tree ssa1,
- tree ssa2) override;
+ void record (basic_block bb, relation_kind k, tree ssa1, tree ssa2) override;
relation_kind partial_equiv (tree ssa1, tree ssa2, tree *base = NULL) const;
- relation_kind query_relation (basic_block, tree, tree) override;
- relation_kind query_relation (basic_block, const_bitmap, const_bitmap)
- override;
+ relation_kind query (basic_block, tree, tree) override;
+ relation_kind query (basic_block, const_bitmap, const_bitmap) override;
void dump (FILE *f, basic_block bb) const override;
void dump (FILE *f) const override;
@@ -222,13 +219,12 @@ public:
dom_oracle ();
~dom_oracle ();
- void register_relation (basic_block bb, relation_kind k, tree op1, tree op2)
+ void record (basic_block bb, relation_kind k, tree op1, tree op2)
final override;
- relation_kind query_relation (basic_block bb, tree ssa1, tree ssa2)
+ relation_kind query (basic_block bb, tree ssa1, tree ssa2) final override;
+ relation_kind query (basic_block bb, const_bitmap b1, const_bitmap b2)
final override;
- relation_kind query_relation (basic_block bb, const_bitmap b1,
- const_bitmap b2) final override;
void dump (FILE *f, basic_block bb) const final override;
void dump (FILE *f) const final override;
@@ -269,11 +265,10 @@ public:
path_oracle (relation_oracle *oracle = NULL);
~path_oracle ();
const_bitmap equiv_set (tree, basic_block) final override;
- void register_relation (basic_block, relation_kind, tree, tree) final override;
+ void record (basic_block, relation_kind, tree, tree) final override;
void killing_def (tree);
- relation_kind query_relation (basic_block, tree, tree) final override;
- relation_kind query_relation (basic_block, const_bitmap, const_bitmap)
- final override;
+ relation_kind query (basic_block, tree, tree) final override;
+ relation_kind query (basic_block, const_bitmap, const_bitmap) final override;
void reset_path (relation_oracle *oracle = NULL);
void set_root_oracle (relation_oracle *oracle) { m_root = oracle; }
void dump (FILE *, basic_block) const final override;
--
2.41.0