aboutsummaryrefslogtreecommitdiff
path: root/gcc/value-relation.h
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2021-09-17 09:48:35 -0400
committerAndrew MacLeod <amacleod@redhat.com>2021-09-17 14:06:15 -0400
commit534c5352a02485a41ebfb133b42edbbecba7eba3 (patch)
treeccb6e2e2a07b87cd0ddd33df9553e1eea6eab188 /gcc/value-relation.h
parent3674d8e6fc6305507ed50b501f049f25f868458a (diff)
downloadgcc-534c5352a02485a41ebfb133b42edbbecba7eba3.zip
gcc-534c5352a02485a41ebfb133b42edbbecba7eba3.tar.gz
gcc-534c5352a02485a41ebfb133b42edbbecba7eba3.tar.bz2
Provide a relation oracle for paths.
This provides a path_oracle class which can optionally be used in conjunction with another oracle to track relations on a path as it is walked. * value-relation.cc (class equiv_chain): Move to header file. (path_oracle::path_oracle): New. (path_oracle::~path_oracle): New. (path_oracle::register_relation): New. (path_oracle::query_relation): New. (path_oracle::reset_path): New. (path_oracle::dump): New. * value-relation.h (class equiv_chain): Move to here. (class path_oracle): New.
Diffstat (limited to 'gcc/value-relation.h')
-rw-r--r--gcc/value-relation.h51
1 files changed, 49 insertions, 2 deletions
diff --git a/gcc/value-relation.h b/gcc/value-relation.h
index 323b1e6..574fdc9 100644
--- a/gcc/value-relation.h
+++ b/gcc/value-relation.h
@@ -98,8 +98,18 @@ public:
void debug () const;
};
-// Declared internally in value-relation.cc
-class equiv_chain;
+// This class represents an equivalency set, and contains a link to the next
+// one in the list to be searched.
+
+class equiv_chain
+{
+public:
+ bitmap m_names; // ssa-names in equiv set.
+ basic_block m_bb; // Block this belongs to
+ equiv_chain *m_next; // Next in block list.
+ void dump (FILE *f) const; // Show names in this list.
+ equiv_chain *find (unsigned ssa);
+};
// The equivalency oracle maintains equivalencies using the dominator tree.
// Equivalencies apply to an entire basic block. Equivalencies on edges
@@ -188,4 +198,41 @@ private:
};
+// A path_oracle implements relations in a list. The only sense of ordering
+// is the latest registered relation is the first found during a search.
+// It can be constructed with an optional "root" oracle which will be used
+// to look up any relations not found in the list.
+// This allows the client to walk paths starting at some block and register
+// and query relations along that path, ignoring other edges.
+//
+// For registering a relation, a query if made of the root oracle if there is
+// any known relationship at block BB, and it is combined with this new
+// relation and entered in the list.
+//
+// Queries are resolved by looking first in the list, and only if nothing is
+// found is the root oracle queried at block BB.
+//
+// reset_path is used to clear all locally registered paths to initial state.
+
+class path_oracle : public relation_oracle
+{
+public:
+ path_oracle (relation_oracle *oracle = NULL);
+ ~path_oracle ();
+ const_bitmap equiv_set (tree, basic_block);
+ void register_relation (basic_block, relation_kind, tree, tree);
+ relation_kind query_relation (basic_block, tree, tree);
+ relation_kind query_relation (basic_block, const_bitmap, const_bitmap);
+ void reset_path ();
+ void dump (FILE *, basic_block) const;
+ void dump (FILE *) const;
+private:
+ void register_equiv (basic_block bb, tree ssa1, tree ssa2);
+ equiv_chain m_equiv;
+ relation_chain_head m_relations;
+ relation_oracle *m_root;
+
+ bitmap_obstack m_bitmaps;
+ struct obstack m_chain_obstack;
+};
#endif /* GCC_VALUE_RELATION_H */